sounds like your alternator is not working. maybe you have a bad connection or you might need to replace your alternator. It seems you car was running off of your battery but when you turned on your headlights your battery ran down fast due to the high current draw of the headlights. your battery probably kept wearing down until it hardly had enough power to fire your plugs (hence the sputtering), and then finally went dead.