Endorphins were nature's painkillers, produced in the pituitary gland and hypothalamus of all humanoids.
Human had a nerve cluster behind the carotid artery and the ear that served as a neural pressure point. If an individual tapping on location, through process called "plexing", they stimulated the part of the brain that released natural endorphins. (TNG: "Realm Of Fear")
The Cardassian Obsidian Order provided its operatives with cranial implants that stimulated the pleasure centers of the recipient's brain to trigger "vast amounts" of natural endorphins, thus allowing the wearer to resist pain, and thus, torture. When Elim Garak became addicted to his reliance on the implant, he was asked by Doctor Julian Bashir why he didn't just shut it off. Garak explained that after two years, his body had become completely dependent on the higher endorphin levels generated by the implant, and that he couldn't turn it off. (DS9: "The Wire")
Bajoran females produced Endorphins during labor. (DS9: "The Begotten")
The naturally occurring neurochemical endorphins were described by the Star Trek Encyclopedia, 4th ed., vol. 1, p. 241 as opiate peptides similar to the drug morphine, which acted upon the nervous system to affect sensations of pain and pleasure.