Questions about HOCD are the most asked about questions on the forum. All you have to do is scroll through the questions and you will see this. I think the reason is because it is hard to get closure on this thought.
I know gay people and they knew from an early age that they were gay or at least had an inkling. Think about how your body responds when you see somebody you are attracted to. You can't make up what you feel. Your body responds without thought.
So if you stand up right now and say out loud "I'm gay" would you want to run out and get a boyfriend or girlfriend and be intimate with them? If the answer is no, then you cannot possibly be gay.
Actually, this is actually what you should be doing. Say "I'm gay, whatever" whenever the thought pops into your head. After a while you will just become sick of it and it will no longer control you. You need to take the fear out of the thought. It isn't going to happen overnight so work at it.
A good book is called self-coaching by Joseph Luciani