It seems it varies a lot from one kid to another. That mostly based on what I read on the internet, and for the most part on the SDMB, not on any scientific study or serious articles I read.
I had sexual interests (even though I didn’t know that “sexual” was a thing) early on (I could recently date it precisely at the age of 7 at the latest), and they even already included things that would stay my sexual kinks. While I discovered that many people seem to have had exactly zero sexual feelings until they reached puberty.
Also, many people discover masturbation very early, some even unable to remember a time when they didn’t masturbate, so before 4 or so. Having discovered it late (at 13), I wouldn’t know personnally how it goes for small kids. They could masturbate just for the physical pleasure, or they could fantasize like teens and adults do. However, I remember reading in autobiographies about kids (pre pubescent) fantasying about women while masturbating. So, they had to have both sexual interests and a defined sexual orientation early on. Probably people who began to masturbate early could tell whether they had such fantasies or not and since when.
On the other hand, my own sexual orientation only became clear quite late, during my teens. The earliest you go, the more “bisexual” I was. Even though I think I always had a preference for girls, I had an interest in boys too, and I wasn’t blatantly more heterosexual during my teen years. Incidentally, a large number of people don’t believe that such an ambivalent “phase” can actually exist during adolescence, assuming that those kids are either pretending to have homosexual interests to make themselves more interesting, or pretending to have heterosexual interests because they reject their homosexuality. Presumably, people project their own experience (sexual orientation clearly determined early on) and assume it’s the same for everybody. It irritates me quite a lot since I know for a fact that one’s sexual orientation can be “undetermined” at 15. And it’s not even bisexuality, because it eventually turned out that I was heterosexual (at least 99% so). Or at best, if not undetermined, it’s a real “bisexual phase”.
Finally, I would mention that a friend of mine discovered he was homosexual around 40. This completely floored me that one could live so long without knowing it. Even more so since I had been certain he was homosexual (but not disclosing it) since I had known him, based on his behaviour around men (and wrongly assumed that his business associate was in fact his lover). It really was a revelation for him (he met a guy, fell in love, and from then on, was homosexual), he told me that he never had homosexual thoughts or fantaisies before. I still can’t understand how it’s even possible.
So, to sum up, people are different, and you can’t assess that sexual orientation is fully determined at birth and unchanging. This narrative IMO is more political (and even more specifically American, intended to fight the “homosexuality is a sinful choice” narrative common there. The idea was at first poorly received by the French gay community, for instance) than real. I do not deny that many homosexuals might have felt so since early childhood, I just state that it isn’t an universal experience. And in particular, many people seem to have had no kind of sexual interestat all, hence no sexual orientation, until puberty (even though it could have been latent, at least they weren’t aware of it).
I believe that sexual orientation is more fluid than most people assume, and quite a lot dependant on culture. I base this idea not only on my own experience, but on the existence of societies like classical Greece where homosexuality and homosexual love (as opposed to simply sex) was widespread, which couldn’t happen if there was only some fixed and small percentage of the population that was born homosexual, and on the prevalence of homosexual sex and homosexual relationships when men are stuck together (prisons for instance), which IMO couldn’t happen either if many people didn’t have a latent potential for homosexual attraction (I personnally can’t see how I could want to have sex with someone I’m utterly unattracted to due to biological factors, and I don’t think that I’m alone).
Basically, I believe that besides a relatively limited subset of the population that is absolutely, 100% homosexual or heterosexual, most people have a potential for both, with a more or less marked preference for either, and that this potential will be expressed or not, ignored or recognized, nurtured or repressed, depending on environmental factors, like culture and life experiences. I believe people are very different wrt sexuality (or wrt anything else, for that matter), and that most generalizations made (including those made by gay rights advocates, for instance) are wrong and based on either assuming that one’s own experience is universal and/or a desire to make everybody fit in convenient and simple categories.
Hmm…I guess this post would fit better in GD or IMHO than GQ, sorry for that.