This is the advice I wish I had received when I started writing erotic stories. It's not universal, but if you're a beginning writer I believe you will do better to keep these tips in mind.
-Sex Should Show Character-
A good sex scene is more than just a sex act described. Aside from being pleasurable to imagine, it also incorporates characters' personalities and relationship, and it even helps to define them a little.
In Gladiatrix, by Brianna_Tease, the titular protagonist wins a gladiatrix match and is rewarded with a massage given by her choice out of nine men. When the masseur offers to please her more intimately, she is hesitant at first. Then she grows comfortable with having a soft-handed hunk of a man all to herself, and eventually she orders him to bring her to multiple orgasms. This sex scene is more than just sex. It shows the gladiatrix getting accustomed to sex as a reward, getting over her shyness and also learning the perks of her new lifestyle.
Whenever I write sex scenes, I make sure that the characters' words, body language and even their choice of sex acts reflect their relationship. In my story Her Finest Steal, when a female thief manages to tie down an adventurer-prince and get the key to his chastity cage, she doesn't immediately have sex with him. She pauses to brag about how she outsmarted the prince, she gushes about how pretty and valuable he is, then finally rides him with no foreplay. That way, the scene is more than just sex. It's also a scene where a thief congratulates herself for her latest steal, and it shows that she's bowled over by what she's achieved. Her behavior makes the scene distinct.
-Sex Should Advance the Plot-
An erotic story is a kind of romance story, and in any romance story the characters and their feelings drive the plot. And since sex is often an expression of romantic feeling, it should coincide with turning points in the plot or, better yet, drive the plot.
For example, in the first chapter of Taiyakisoba's story Monsterboy Quest, the main character, a retired knightess on a quest from her cloister, revels in the freedom of trekking through the wilds, and when a monster boy deals her a glancing blow with his aphrodisiac venom, she pins him down and ravishes him with suspicious verve. Not only is it a fun scene to read, it's also a clear sign that the knightess was a poor fit for monastic life and her wanderlust—and regular lust—are still potent.
In reality, of course, people have sex even when it doesn't represent a turning point in their character arcs. But in a story, sexual encounters like that should happen offscreen, because they don't contribute to the plot or characterization.
-Outline The Whole Story, Then Write the Important Parts First-
This is the most important lesson I've learned.
It's most intuitive to start writing story at the beginning, write everything in order and write the ending last. But I find that it's better to write the scenes you're most excited about first, then write the connective tissue between them. That way, you'll get your best scenes out before inspiration fades, and you'll have a better sense of what the remaining scenes should look like. This makes editing easier.
For example, in my story A Symbolic Message, I wrote character bios first, then a general plot, then I wrote some exchanges between the two main characters just to get a feel for how they would play off each other. A lot of this dialogue didn't make the final cut. Next, I wrote a plot synopsis that explained what happened in each scene and why it was important. The first draft of the synopsis looked something like this:
Opening lines to set the tone.
Mel gets off a plane. Establish that he's new in this setting and he's disgusted by the poverty he sees.
He meets the female lead. They form a team. Establish him as brash and easily offended. Establish her as annoyed with him, but patient with him.
They go to the nightclub. He whores himself out. She gets information.
And so on. I went through the skeleton a few times, touching things up, adding details and character beats and writing down what the themes of the story were. Then, and only then, I started writing scenes in full prose. I started with the climactic sex scene, then the scene where the two leads meet, then the opening scene. If I had written the scenes in chronological order, the work would have been slower, more confusing and less engaging.
There's another advantage to writing scenes out of order: whenever I got a kinky idea, I would find a place where I could write it into the story and use it to make the world feel more real. For example, the story was already mostly finished when I came up with the scene where a woman takes her blindfolded boyfriend to be transformed into a monster boy, with him none the wiser. I used that scene to show how, in a world that doesn't value male autonomy, even kind-hearted women will take away men's free will. If I hadn't written a plot synopsis first, I wouldn't have known where to put that scene.