Written by Emily Nagoski, Ph.D.
Well, so there's the "dream" part of the question and then there's the "sex" part of the question.
Dreaming itself is still a bit of mystery. We mostly dream during REM sleep, with its deep, slow brain waves and total physical paralyzation (except for your eyeballs, of course). All of us dream every night. Many people don't remember our dreams, but everyone dreams every night, unless there is something seriously wrong.
Sex dreams tend to happen most during REM sleep. REM dreaming in general, runs my preferred theory, probably functions as worst-case-scenario type preparation, taking all the things that happened today and all the things that led up to those things, along with all the things that may happen tomorrow, loading it all up like a neural trebuchet, and firing it, BLAM, across the brain. The result is a bit of a mess as far as your rational mind is concerned, so when you're remembering it in a conscious state you're like, "What. The. Fuck?" but ultimately it's like rehearsal for life.
So much for REM dreaming.
Now, throughout the sleep cycle, your brain oscillates through degrees of disinhibition. (See the dual control model for full explanation, but briefly this means turning off the sexual "brakes" that stop you from being aroused during inappropriate situations.) This is the best explanation I know for why REM is also when people with penises experience nocturnal penile tumescence (LOVE. LOVE. LOVE that phrase).
(FYI: morning wood is waking up around a REM phase; it has nothing to do with being horny and everything to do with just being asleep and healthy. The horny in the morning thing is actually about testosterone levels being highest at the start of the day and gradually lowering as the day ages.)
So, during REM, your brain is disinhibited and there's this BLAM of life happening in your brain. Sometimes sex is the dominant thing in the BLAM. Sometimes it's school or family or a movie you just saw or a book you just read or whatever. Sometimes it's food. But sometimes it's sex.
Non-REM (NREM) dreaming, on the other foot, tends to be more about motor coordination, rehearsal and integration. Anyone who plays a sport or an instrument, who is learning a motor skill or memorizing anything will rely on non-REM sleep in order to maximize their potential. If you're practicing the stop-start technique, NREM is probably when your brain is rewiring to make you better at ejaculatory/orgasmic control. So you might have sex dreams then, too.
When do people start having them? Well, dreams that APPEAR sexual to adults typically begin around puberty, with the onset of hormonal changes. But children have their own brand of sexuality and I'm totally sure they sex makes it into their dreams, but in a totally different, self-centered, charmingly childish way. In the way that children masturbate at nap time, they dream sexually. It's not sexual in the way that adolescents and adults are sexual, but it's its own kind of sexual.
Altogether, dreams don't mean much. They don't indicate anything about you as a person, you can't interpret them in any organized way. Dreaming about doing some sexual thing does not necessarily mean you want to do that thing in real life; dreaming about sex with someone does not mean you want to have sex with them in real life, though it also doesn't mean you DON'T want to have sex with them in real life. It just means that that person and sex were in the neural trebuchet together. It happens.
That said, how you feel about the dream as you remember it may indicate something or other. Like, "Wow, last night I dreamt that Jamie and I got it on. Damn, that was HOT. Jamie is HOT. Maybe I want Jamie!" What indicates the wanting is not the fact that you had the dream nor even the fact that you remembered the dream, but the emotional experience you had in response to that memory. Dig? Okay.