Your target needs to have the heavy sleeper perk (one of the first that can be unlocked, under the Physique branch). Then, while they're sleeping (not necessarily with you, per se, e.g. for house guests; and further their actual sleeping hours will be different depending on their species), you can trigger sleep sex with them. It's only reliable for slaves and guests, two people where you get some manner of say with their perk distribution.
You can also have it happen to yourself if you have the perk, and a slave assigned to sleep in your bedroom also has the "Use you" permission, in which case they'll initialize sleep sex.