If you are concerned that your crush on your teacher is impacting your day-to-day life and also preventing you from concentrating on your studies, talk to a therapist or school guidance counselor. If you are concerned about privacy, talk to a therapist rather than a guidance counselor. Your therapist is required by a code of ethics to keep what you say confidential. Guidance counselors are not bound by the same code, and can easily report information that's revealed to them. Your friends may have similar experiences coping with crushes and might be able to offer some interesting advice or perspective. If nothing else, talking about your feelings might make you feel less alone. If you find yourself unable to stop thinking about or interacting inappropriately with your teacher, it might be time to make a more drastic change. Talk to your guidance counselor or academic advisor about transferring out of the class. Be honest with your counselor about the feelings you're having for your teacher. If they don't fully understand how much these feelings are distracting you from your schoolwork, they might not be willing to let you change classes. Trust that they are professionals who are trained to deal with situations like this.
Speak with a licensed professional. Talk with your friends. Transfer out of the class.