Tim Stretton has posted a fine piece on his blog about writing sex scenes.
Lawrence Block once raised the question as to whether a sex scene could ever be gratuitous if it were in a sex novel. As I've been on the topic of books on writing, allow me to also point to Susie Bright's How to Write a Dirty Story.
Susie--of Susie Sexpert fame, founder of the women's magazine On Our Backs, and author of the fine short story Dan Quayle's Dick) would probably deny there is ever such a thing as gratuitous sex. (Alas, guys, Susie is a lesbian, and therefore not in our dating pool.)