What is a DAC?
A DAC is a Digital-to-Analog Converter
A DAC [Digital-to-Analog Converter] is a device that converts digital audio information (comprised of a series of 0s and 1s) into an analog audio signal that can be sent to a headphone amp.
In most cases, you can not connect a headphone directly into a DAC. Thus, a headphone amp must serve as the intermediary step between a DAC and your headphones.
The most popular DAC connection method is via USB from a computer. There are also digital feeds available from Optical and Coaxial outputs -- also known as SPDiF connections -- found on CD/DVD players and other audio gadgets that can connect into a DAC. Modern smartphones can even be hooked into outboard amp/DACs, typically by using sundry interconnect cables and adapters.
Remember that lossy (low bitrate) MP3 files will always lack detail and dynamics so the most important thing to improve your headphone sound quality is to rip your digital music in uncompressed formats or at the highest possible bitrate for best sound quality.
What Does a DAC Do?
So to truly understand how a DAC functions, we should first understand what an analog signal is.
An analog audio signal is a continuously varying voltage that perfectly represents (or is analog-ous) to the continuously varying sound wave that you hear.
For example, a microphone turns incoming sounds into an analog electrical signal representing those sounds; room speakers convert an analog electrical signal back into the original sound (or as close as possible).
But how does one store an analog signal? A half-century ago, one would store an analog signal as a groove on an LP record that moves the needle back and forth during playback to create an electrical analog signal representing the stored sound.
Nowadays, we repeatedly sample and measure the height of the analog signal over time, and then store that series of numbers on a hard-drive or memory of an audio device. This series of 0s and 1s numbers is a digital audio signal.
A CD disc stores these samples as 16-bit binary (1s and 0s) "words" 44,100 times a second - aka 16-bit/44kHz files - but digital audio data can be stored in a variety of sample rates, word sizes, and encoding or compression formats.
In every case, the last thing that happens is the digital numbers get converted back into an analog electrical signal that can be sent to a headphone amp, then your headphones - the device that does this is called a digital to analog converter, or a DAC!
A standalone DAC that's separate from the source device being used for playback allows for for clean implementation of the chip that's doing the conversion, and this can have a significant impact on overall clarity of what you hear. The degree of performance gained is influenced both with the quality of the DAC chip being used (and its characteristics), and the quality of the chip's implementation with the rest of the circuitry required.
The rule of thumb for a DAC is that if you go from using an on-board or built-in system, moving to a standalone DAC or DAC/amp combination will make a substantial improvement for most headphones. But if you already have a standalone DAC, differences from one to the next won't be as significant.
DACs also often report bit depth and sample rates that don't have any tangible impact on the sound quality, such as 32bit at 768khz (samples per second), so it's not possible to determine the quality of a DAC just by looking at specs alone.
This is a bit like headphone and speaker specifications that indicate 20-50khz while in reality anything above 20khz is beyond the range of human hearing anyway. The quality of the components being used in the system, and the type of DAC chip being used, do however make an important difference.