What exactly are the functions of an aviation headset?
Aviation headsets are just like gaming headsets on a computer or console gaming system, except they are sturdier and much more expensive.

At the basic end of the spectrum, an aviation headset is just a big clamp style pair of around the ear headphones with a microphone.  The cable from the headset has 2 plugs (for airplanes) or one plug (for helicopters).  These two plug styles are equivalent electronically, with the helicopter cable having an extra conductor in order to include the microphone and headphones in the same plug. The two-plug variant has one plug for the headphones and one of the microphone.  These differ from gaming headsets in that the headphone plug is 0.25" (the kind a nice stereo receiver uses) and the microphone plug is 0.206".  This difference in sizes is to avoid mixing up which plug goes in which jack.

Aviation headsets fall into two broad categories: passive noise reduction and active noise reduction (ANR).  The passive noise reduction headsets rely on a good seal around the ear and a strong clamping force (e.g. David Clarks).  Active noise reduction are somewhat less "clampy" and provide less passive protection but make up for this with the active protection.  An ANR headset is money well spent, but these do top out at around \$850-\$1000 for the top models from Lightspeed and Bose respectively.  ANR headsets must be powered to work properly but all ANR headsets still function without power as passive noise reducing headsets.  Power for an ANR headset can come from a battery box or from aircraft power but not interchangeably.  Aircraft power requires panel installation of a plug specific to the headset brand (a single connector provides power, headphone and microphone connections).  In general, unless you happen to own an airplane and install the power plug, you should get the battery version of a headset.

The primary purpose of these headsets is to reduce the noise in the cockpit (they can be very loud) in order to avoid hearing loss (yes, it is that loud) and to facilitate clearer communication with ATC.  

For quieter airplanes there are in-ear headsets that have more in common with earbuds than the bigger headsets.  Some of these are just earplugs wired for sound and some use molds of your ear to provide the seal.  



The headset is connected to the airplanes audio panel.  Audio panels vary in complexity but their basic job is to provide an intercom for communication between occupants of the airplane and access to the com radio for communication with ATC.  The audio panel is also able to monitor (listen) the navigation radios certain types of beacons.  In transport aircraft the audio panel is also tied into the passenger address system and the flight attendant's phones in the cabin.

The headsets can be operated in a hot mic setup or the mic can be explicitly turned on and off.  The hot mic is the usual method and the audio panel provides a squelch control so you aren't broadcasting the cockpit noise when not talking.  The ATC transmissions are via a push-to-talk (PTT) switch.  



Aviation headsets for the most part do not need to be approved to use in airplanes, but in some situations for US registered aircraft, the requirement of an approved headset can be mandated (some (all?) 121 carriers).  The FAA standards for approval are specified in TSO C-57a and C-58a.  You'll find many, but certainly not all, aviation headsets conform to these orders.  They define minimum performance characteristics of the electronics, speakers, microphones, etc that make up the headset.



How much hearing protection is needed depends greatly on the specific airplane in question.  Jets can be on the very loud end of the spectrum (EMB-145) or they can be quiet enough that even passive noise reduction is largely unnecessary.  For the noisy end of the spectrum peak wavelengths can be well in excess of 100 dB.  I can find reports of 130 db in some smaller airplanes and reports of 84 db in a 737 during cruise, but these numbers are all anecdotal in nature.  What is important to take from these is not the specific numbers but that they are high enough to cause hearing loss during prolonged exposure.  The National Institute on Deafness and Other Communication Disorders defines 85 dB as the threshold for hearing damage from long or repeated exposure. 

Passive headsets generally advertise noise reduction around 20 dB (23 dB for the venerable David Clarks) and some people will wear earplugs under a headset to further increase the passive noise reduction. A cursory look at ANR headsets reveal that they tend not to advertise their performance and instead specify maximum ambient noise levels for ANR to properly function (around 120-125 dB for Bose and Lightspeed headsets).  I can personally add an anecdote that both the Lightspeed Zulu and Bose X make dramatic changes in noise level (both of these headsets are now outdated and replaced by newer versions).  

For most smaller airplanes you will wear the headset from startup to shutdown.  As you get into the large jets I have observed crews that wear minimal headsets during takeoff and landing, but not always during cruise.  These airplanes were quiet enough that they were not needed.  On turboprops and smaller jets that I have been in, headsets were worn throughout the flight.  



On newer ANR headsets in particular you will find some extra features beyond just being a pair of headphones and a microphone.  These extras include a 3.5 mm auxiliary jack to connect external music and bluetooth to connect your phone or other device to the headset.  These typically come with circuitry to automatically mute or greatly decrease the volume of these inputs when ATC is transmitting.