In many cultures, sexuality was the physiological or emotional drive responsible for physical attachments stemming either from a biological or societal need to bond with a mate. This adaptation primarily facilitated sexual reproduction, however, even those attracted that could not or did not reproduce still had a deep-seated need for the kind of satisfaction a mate provided. In many cases, the ties contributed to causing permanent or long-lasting sexual relationships, which could be monogamous or polygamous. Some species, like Vulcans, had a telepathic bond which formed between mates. (TOS: "Amok Time")
Many species had complex interactions (see mating rituals) and communications involved in approving or rejecting a potential mate. Chemical adaptations such as attractive pheromones or biochemical bonds were also evolved by some lifeforms, such as Orions and Varro. (ENT: "Bound";VOY: "The Disease")
Deltans were also known to project a strong sexual presence even without physical contact, which might have included pheromones and some subconscious telepathic elements. The effects were sufficiently strong as to influence other species. (Star Trek: The Motion Picture)
This drive could also lead individuals to enter a relationship or mate for reasons of satisfaction or emotional fulfillment rather than procreation. Individuals of many species were also known to enter into homosexual relationships. Many individuals encountered in the mirror universe were known to seek out homosexual attachments. (DS9: "The Emperor's New Cloak")
While Beverly Crusher ended her relationship with Odan in female form and Jadzia Dax ended her relationship with Lenara Kahn, the reasons given were not due to sexual preference. Crusher cited the changing of host bodies and Dax's reason was the taboo act of reassociation. (TNG: "The Host"; DS9: "Rejoined")
The Doctor had to upload his program to Seven of Nine, effectively taking over her body and being in full control of it. Seven of Nine was mentally aware of The Doctor becoming sexually aroused in her body while being massaged by Doctor Jaryn. (VOY: "Body and Soul")
Some cultures, such as the J'naii, were known to enforce laws prohibiting the occurrence of sexual acts considered deviant by the majority of the population. In their case, any individual who adopted a gender was given psychotectic treatments to restore them to the species' androgynous norm. (TNG: "The Outcast")
In the 24th century, Starfleet personnel apparently required permission from a CMO and their commanding officers to engage in sexual relations with members of alien species, although this formality was only shown being observed once on board USS Voyager. (VOY: "Prophecy") Nevertheless, its breach was the basis for a reprimand being entered into Harry Kim's permanent record. When Kathryn Janeway informed Kim of the reprimand, she indicated that the regulations on inter-species sexual contact were "three centimeters thick." (VOY: "The Disease")
In the 24th century, gender-reassignment surgery, otherwise known as a sex change, was known to be performed. In 2374, Dr. Bashir performed such surgery on Quark with no complications or special preparations mentioned. The surgery performed on Quark was more than mere facial cosmetics: Bashir injected female hormones into Quark, and, eventually, Quark removed his clothing to prove that he was a "real" female. The onlooking businessman noted that Quark looked like a female, indicating that Bashir had made physical changes to the chest and/or genital areas of Quark's body. (DS9: "Profit and Lace")
Background information Edit
A cut line in "Paradise" had the self-proclaimed philosopher Alixus claim that she had a lot to say about sexuality, which she believed would shock someone as repressed as Benjamin Sisko seemed to her. This apparently included the acceptability of sexual procurement.
Homosexuality in Star TrekEdit
George Takei recalled that during the production of Star Trek: The Original Series he had asked creator Gene Roddenberry why there were no gay or lesbian characters in the series. According to Takei, "He said 'I'm treading a fine tight wire here. I'm dealing with issues of the time. I'm dealing with the civil rights movement, the Vietnam War, the Cold War, and I need to be able to make that statement by staying on the air.' He said, 'If I dealt with that issue I wouldn't be able to deal with any issue because I would be canceled.'" 
Ronald D. Moore during the production of Season 6 of Star Trek: Deep Space Nine stated that the show was not interested in stories about homosexuality, or revealing any main character as bi or gay, because it would not really be an issue to them, and so "exploring" it did not hold much promise. He did not disagree that maybe the show should do stories in this vein, but felt that he was more passionate about other issues and therefore should write about that. (AOL chat, 1997)
It was not until 2016 that a regular character was depicted as openly gay. In that year, Star Trek Beyond was released and depicted Hikaru Sulu as having a husband, Ben. The following year, Star Trek: Discovery premiered, with series regular Paul Stamets in a relationship with the recurring character of Hugh Culber. Stamets became the first character to specifically describe himself in dialogue as gay (also so describing Culber) in DIS: "The Red Angel". In relation to Stamets, Bryan Fuller commented, "Star Trek started with a wonderful expression of diversity in its cast...we're continuing that tradition."