Most religions have rigid, elaborate rules about sexual conduct. Buddhists have the Third Precept -- in Pali, Kamesu micchacara veramani sikkhapadam samadiyami -- which is most commonly translated "Do not indulge in sexual misconduct" or "Do not misuse sex." However, for laypeople, the early scriptures are hazy about what constitutes "sexual misconduct."
Most monks and nuns follow the many rules of the Vinaya-pitaka. For example, monks and nuns who engage in sexual intercourse are "defeated" and are expelled automatically from the order. If a monk makes sexually suggestive comments to a woman, the community of monks must meet and address the transgression. A monk should avoid even the appearance of impropriety by being alone with a woman. Nuns may not allow men to touch, rub or fondle them anywhere between the collar-bone and the knees.
Clerics of most schools of Buddhism in Asia continue to follow the Vinaya-pitaka, with the exception of Japan.
Shinran Shonin (1173-1262), founder of the Jodo Shinshu school of Japanese Pure Land, married, and he authorized Jodo Shinshu priests to marry. In the centuries that followed, the marriage of Japanese Buddhist monks may not have been the rule, but it was a not-infrequent exception.
In 1872, the Meiji government decreed that Buddhist monks and priests (but not nuns) should be free to marry if they chose to do so. Soon "temple families" became commonplace (they had existed before the decree, actually, but people pretended not to notice) and the administration of temples and monasteries often became family businesses, handed down from fathers to sons. In Japan today -- and in schools of Buddhism imported to the West from Japan -- the issue of monastic celibacy is decided differently from sect to sect and from monk to monk.
The Challenge for Lay Buddhists
Let's go back to lay Buddhists and the vague precaution about "sexual misconduct." People mostly take cues about what constitutes "misconduct" from their culture, and we see this in much of Asian Buddhism. However, Buddhism began to spread in western nations just as many of the old cultural rules were disappearing. So what's "sexual misconduct"?
I hope we can all agree, without further discussion, that non-consensual or exploitative sex is "misconduct." Beyond that, it seems to me that Buddhism challenges us to think about sexual ethics very differently from the way most of us have been taught to think about them.
Living the Precepts
Further, the precepts are principles, not rules. It's up to us to decide how to apply the principles. This takes a greater degree of discipline and self-honesty than the legalistic, "just follow the rules and don't ask questions" approach to ethics. The Buddha said "be a refuge onto yourself." He taught how to use our own judgments about religious and moral teachings.
Followers of other religions often argue that without clear, external rules, people will behave selfishly and do whatever they want. This sells humanity short, I think. Buddhism shows us that we can release our selfishness, greed and grasping -- maybe never entirely, but we certainly can reduce their hold on us -- and cultivate loving kindness and compassion.
Indeed, I would say that a person who remains in the grip of self-centered views and who has little compassion in his heart is not a moral person, no matter how many rules he follows. Such a person always finds a way to bend the rules to disregard and exploit others.
Specific Sexual Issues
Marriage. Most religions and moral codes of the West draw a clear, bright line around marriage. Sex inside the line, good. Sex outside the line, bad. Although monogamous marriage is the ideal, Buddhism generally takes the attitude that sex between two people who love each other is moral, whether they are married or not. On the other hand, sex within marriages can be abusive, and marriage doesn't make that abuse moral.
Homosexuality. You can find anti-homosexual teachings in some schools of Buddhism, but I believe most of these are taken from local cultural attitudes. My understanding is that the historical Buddha did not specifically address homosexuality. In the several schools of Buddhism today, only Tibetan Buddhism specifically discourages sex between men (although not women). This prohibition comes from the work of a 15th century scholar named Tsongkhapa, who probably based his ideas on earlier Tibetan texts. See also "Did the Dalai Lama Endorse Gay Marriage?"
Desire. The Second Noble Truth teaches that the cause of suffering is craving or thirst (tanha). This doesn't mean cravings should be repressed or denied. Instead, in Buddhist practice we acknowledge our passions and learn to see they are empty, so they no longer control us. This is true for hate, greed and other emotions. Sexual desire is no different.
In The Mind of Clover: Essays in Zen Buddhist Ethics (1984), Robert Aitken Roshi said (pp. 41-42), "For all its ecstatic nature, for all its power, sex is just another human drive. If we avoid it just because it is more difficult to integrate than anger or fear, then we are simply saying that when the chips are down we cannot follow our own practice. This is dishonest and unhealthy."
I should mention that in Vajrayana Buddhism, the energy of desire becomes a means for enlightenment; see "Introduction to Buddhist Tantra."
The Middle Way
Western culture at the moment seems to be at war with itself over sex, with rigid puritanism on one side and licentiousness on the other. Always, Buddhism teaches us to avoid extremes and find a middle way. As individuals we may make different decisions, but wisdom (prajna) and loving kindness (metta), not lists of rules, show us the path.