A DAC is a Digital-to-Analog Converter
A DAC [Digital-to-Analog Converter] is an electronic processor inside digital media players that converts digital audio information (comprised of series of 0s and 1s) into an analog audio signal that can be sent to headphones, or better yet, a headphone amp. If you want all those digits inside the player to sound as good as when the music was originally recorded, you need to use a high-quality DAC. The simplest way to get a digital audio signal to an external DAC is via the USB port on your computer, but one can also get a digital feed from the optical and coaxial outputs -- also known as SPDiF connections -- found on CD or DVD players, MAC computers, home theatre/stereo receivers, and other streaming audio gadgets of all kinds. Remember that lossy mp3 files will always lack detail and dynamics so the biggest thing to improve your headphones is ripping your digital music in uncompressed formats or at the highest possible bitrate for best sound quality.
But 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 represents (or is analog-ous) to the continuously varying air pressure of a sound wave that you hear. As 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 a record that moves the needle back and forth during playback to create an electrical analog signal representing the stored sound.
Today, we repeatedly sample and measure the height of the analog signal over time, and then store that series of numbers on the hard disk or in flash memory of an audio player. This series of 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, but digital audio data can be stored in a variety of sample rates, word sizes, and encoding or compression formats, and are brought to you on everything from your smartphone to your laptop. But 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 your headphones or headphone amp. The device that does this is called a digital to analog converter, or a DAC!