1. Make sure your headlights are turned off when the car isn't running
It's an obvious piece of advice, but since headlights are an easy way to completely drain your battery, and doing that even a few times is the fastest way to shorten the battery's overall life, it bears repeating.
Newer cars usually have an "auto" setting that automatically turns headlights on when it's dark out, and off when there's enough daylight or the car is turned off. If your car has this feature, it's best to use it all the time.
Some cars turn the lights off when you open the door to get out, even if they're left in the "on" setting. But these mechanisms rely on sensors and can stop working over time, so keep an eye on them as your car ages to avoid surprise dead batteries.
If you turn your car off but stay in it for whatever reason, make sure to turn off the headlights—once the engine is off, they begin draining the battery.