Just having some gay/lesbian thoughts does not make you gay or lesbian. If you experiment with a partner and you enjoyed it then I would consider a person gay or lesbian.
So my answer in a nutshell would be: People know only after they participate in gay/lesbian acts with a partner.
It really is based on whether or not you are attracted to the same sex. And truthfully, it is something that you have to trust your gut about. I have been attracted to men for as long as I can remember; I had crushes on boys in elementary school, I had fixations on male celebrities that I thought were handsome. But since I am from the South and was raised Christian, I just assumed that these thoughts were irrelevant. I had to like women. I managed to tell myself this throughout puberty, when I would only become aroused at the thought of men, and through high school and college, as the girls I dated freaked me out (I didn't like holding their hands and was way too nervous to kiss them). It wasn't until college that a guy I found attractive revealed to me that he was gay, that I admitted these thoughts to myself and kissed him. That really woke me up, and from that point on I knew I was at LEAST bisexual. Over the next year I realized that, no, I am in fact 100% gay, and I'm incredibly happy now.
So that's really it. It's just something that you know. If you think you might be gay or bisexual, if you are denying thoughts about the same sex, then the only thing you can really do is try it, if that's something you are ready and comfortable with. Society kept me in the closet until I was 21, so I understand how hard of a process it is.