Why do my head lights dim when my bass hits?

The reason your headlights are dimming is because you don't have enough amperage to power everything in your electrical system i.e. amplifier, headlights, A/C etc, etc.

This is bad for a couple of reasons. First it's hard on the the factory components of your vehicle and secondly it's very hard on your audio equipment. When an amplifier is ran at low voltage/ amperage it compensates by out putting DC voltage to keep up with your power demands. DC voltage burns coils and low input power melts amplifier power supplies. Even if it appears that your voltage never goes below 12v you may still have a lack of amperage. If you are experiencing a charging system deficiency you need to calculate your total system current draw to determine what methods will best solve your problem. The most common fixes are adding a high output alternator, additional batteries, and upgrading the wiring from battery to ground, alternator to ground and alternator to battery.