Anesthesia is a compound used to induce unconsciousness in a sentient life form. Anesthesia is used most often in medical procedures. Anesthesia is often also a part of intruder control systems on board space vessels and other installations.
Anesthesia for centuries was used to induce sleep in sentient life forms so that surgical procedures could be performed upon them. Anesthesia was also used to sedate patients who would benefit from sleep. A combination of chemicals is most often used to induce sleep. However, by the 24th century, devices such as alpha wave generators and somatic inducers came in to use. Such devices could cause a humanoid brain to produce certain brain waves which would immediately induce sleep. These types of devices often replaced chemical anesthesia for surgery, and were also used for insomnia - although in this case they were only recommended for occasional use. (TNG episode: "Samaritan Snare"; DS9 episode: "The Passenger"; DS9 novel: Warpath)
On board Federation starships, anesthesia is used in the intruder control system, to prevent the takeover of a starship by hostile forces.
When Khan Noonien Singh and his followers took control of the USS Enterprise (NCC-1701), Captain Kirk used the intruder control system to flood all parts of the ship except the deck he and Spock were on with anesthesia gas. The gas was effective in neutralizing all of Khan's forces, with the exception of Khan himself - who had turned off the anesthesia gas line in engineering. Kirk was able to defeat Khan in combat a short time later. (TOS episode: "Space Seed")
After failing to transport Roga Danar to an Angosian vessel, Danar fled to a cargo bay. Realizing that he was in the room, Captain Jean-Luc Picard ordered the cargo bay flooded with anesthesia gas, however Danar was able to find a spacesuit before the gas could subdue him. (TNG episode: "The Hunted")
Under the influence of nano-technology, Data's judgement was seriously affected. Data tried to commandeer the Enterprise to attack Qo'noS. When he realized that the crew would not help him after he took the stardrive section and separated from the saucer, Data flooded the stardrive section with anesthesia gas. (TNG novel: Foreign Foes)