House are particularly guilty of this trope, as patients seen on this medical drama often develop rare and deadly medical complications stemming directly from or as a byproduct of having had sex. Many audience members who comment about such phenomenon online are eager to dismiss the origin of such stories as the effect of overbearing moral values, or Puritanical upbringings. However, I believe that a different origin of this phenomenon is more likely and/or common amongst writers, and I will attempt to illustrate it herein.
Anyone who has written a piece of fiction may have noticed that, as an author, they have the ability to create and control entire universes within their work. A writer dictates how characters behave, how their lives work, how fate and destiny affect them; the writer decides what form life takes, on what world a given event takes place, etc. For a writer creating a work of fiction, all of reality is mutable. More to the point, all of reality is mutable by them. By creating any work of fiction, a writer endows themselves with absolute omnipotence. Within the world they create, however big or small, the writer becomes the closest thing to God.
However, writers are still human, and humans are not God, or gods, even; we have only human emotions, experiences, and perspectives to draw upon. And now matter how much a writer may try to be objective, that human bias will always color a writer's perception and find its way in the world he or she creates in fiction. More specifically, human writers, when they create characters and the world they occupy, will often feel driven to create conflict and drama by rewarding certain characters and punishing others. This is especially true of writers who, in following the old adage of "write what you know," draw heavily upon their own lives and experiences to write about characters and situations. With this in mind, it is at least a little more understandable that some writers, in depicting a fictional situation, may be consciously or subconsciously petty and/or vindictive with their characters.
Additionally, many people who write have not exactly led the most perfect and/or satisfying lives. One of the strongest drives to write creatively is to create a more favorable world, where people are and events occur as the writer wishes them to - often out of a sense of dissatisfaction with the way things are in reality. Returning to the subject of sex, a writer may have been rejected by a callous lover, or had an unpleasant sexual experience, or denied the experience of sex altogether for one reason or another. Life events such as these can breed resentment of more fortunate individuals who have had different and more favorable experiences. This resentment may develop into rudimentary or full-blown inferiority or persecution complexes. In any case, when a writer feels thusly, one of the most therapeutic activities they can engage in to remedy the feelings is to write themselves a world in which things happened differently.
In such a world, the writer's resentment, combined with the writer's self-endowed omnipotence, can be expressed in the petty or vindictive act of reward and/or punishment. The writer may create a character based on themselves or of a close friend whom they reward with a more pleasant life, filled with favorable experiences. Conversely, they may also create characters based on enemies and people they dislike, whom they punish in various ways. In acts of extreme pettiness, a writer may create a sort of "effigy" character, one with all the blessings and fortunes the writer wishes that they had or feels that they have been deprived of. The writer then strikes down their effigy in terrible, sometimes cruel and horrific ways, as a form of second-hand, imaginary vengeance. In context, a writer who for whatever reason is sexually frustrated might take that frustration out on a character who has had the fortune not to experience the same frustration, robbing them of that fortune in various ways and possibly thrusting him into a situation even worse than the writer's own. A writer who feels that they have had far too little sex might contrive a playboy sort of character who finds himself rejected by all his lovers, and forevermore bereft of that comfort. A character made in the image of a careless companion who gave the writer a venereal disease might be struck down with AIDS or syphilis that is too far along to cure. Young, pretty lovers in high school might be saddled with an unplanned baby who may or may not have a fatal venereal disease, which the lovers themselves may or may not have, and the whole lot may be killed in their prime - a revenge fantasy for someone who felt ostracized or unloved when they were the same age.
In any case, while quite therapeutic for an individual to create such a revenge fantasy or morality play, such constructions are not usually received well by others. The majority of audience members will not have experienced such misfortunes and unpleasantness in their lives, and will look at the writer's treatment of such effigy characters as cruel, unusual, twisted, and unfairly judgmental. The work will likely be derided by viewers as severe and contrived, and perhaps even the mark of an individual who could eventually present a danger to society.
In summation, while they certainly can be the products of lofty moral goals or severely sheltered upbringings, stories in which sex "attacks" those who engage in it can also be fantasies constructed out of simple petty revenge and spite. That is not to say they are inherently bad things - it is far better for an individual to write such problems out in order to vent their frustration, rather than actually going out and contriving for someone who wronged them to be harmed in reality. It is perhaps more preferable, however, that such works remain more private, and do not see quite so much of the light of day as they do now. Having a revenge fantasy is one thing; writing an elaborate script for one is another. But actually exhibiting such a fantasy for mass audiences to see draws attention to a facet of the human personality that is ugly, distasteful, and often outright frightening. It may also be closer to home than one might think; and not very many people are eager to be so introspective, to be forced to look that part of themselves in the mirror and accept it...especially through entertainment media, which is so often used to escape such ugliness in life.
In television today, it is becoming more and more common to see episodes in which the plot appears to revolve around the punishment in some form or another of an individual for daring to engage in sexual intercourse. Shows such as