In the Star Trek Voyager episode "Message in a Bottle" (which is the 14th episode of the fourth season), the following dialogue takes place:
The Doctor: I'm as close to a sentient life-form as any hologram could hope to be. I socialize with the crew, fraternize with aliens. I've even had sexual relations.
EMH #2: Sex? How's that possible? We're not equipped...
The Doctor: Let's just say, I made an addition to my program.
EMH #2: Before you leave, maybe you could download those subroutines into my database.
The Doctor: We'll see.
What prior episode is this an allusion to? The only episode I can recall which may have involved the Doctor having sex is "Lifesigns", where he falls in love with Denara Pel. However I don't recall any explicit or implicit references to sex in that episode.