Obsessive Compulsive Disorder (OCD) Support Group
Obsessive-compulsive disorder (OCD) is a psychiatric disorder, more specifically, an anxiety disorder. OCD is manifested in a variety of forms, but is most commonly characterized by a subject's obsessive (repetitive, distressing, intrusive) thoughts and related compulsions (tasks or rituals) which attempt to neutralize the obsessions.
I also suffer from OCD and am unfortunately very familiar with subtypes of OCD similar to what you are describing -- these types often involve mental compulsions (but can also include the compulsive avoidance of anxiety-provoking triggers and other behaviors performed to reduce anxiety). Believe it or not, concerns over whether one is straight or gay are a relatively common type of OCD, as you may already be aware.
Avoidance and reassurance-seeking compulsions actually fuel your anxiety-provoking obsessive thoughts by training your brain to think that your concerns about being gay are actually important; they only provide short-term relief but backfire in the long term. The disturbing thoughts become more likely to pop into your head in a process of paradoxical reinforcement. Your brain thinks that there is a true threat of danger due to your heightened emotional response to these thoughts. Also, the preoccupation with whether you are gay can change your physiological sexual arousal, further tricking you into questioning whether you might be gay.
The solution -- though not easy and probably more challenging in the short term than performing compulsions, which provide temporary relief -- is not to reassure yourself that you are straight. Peaceful acceptance of the disturbing thoughts is key because the goal is to lower your level of anxiety so that you can stop training your brain to get trapped in the OCD loop. Acceptance of the thoughts and an increased tolerance of uncertainty are musts. This is counterintuitive, I know, and involves great strength of mind. It can take time to achieve but is certainly possible. In your situation, you would need to become okay with thinking to yourself that there is a possibility -- no matter how slight -- that you may be gay since nothing in the world is 100% certain. You would, in short, need to not care and to go about with your life accepting whatever related worries may pop into your mind. Imaginal exposures (as part of exposure and response prevention - ERP - a method of cognitive-behavioral therapy - CBT) could be very helpful. I would recommend seeing a therapist who is aware of primarily obsessive OCD (and many therapists aren't and could make your symptoms worse).
There is a book called Overcoming Unwanted Intrusive Thoughts by Sally M. Winston and Martin N. Seif that elaborates more on what I've described above. I would highly, highly recommend reading this book (it's available in audiobook format, as well). It could really change your life and is the best book I've ever read on OCD.
Best of luck to you! I know that with some effort, you can find peace from these thoughts.