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: