It would be a good idea to install a headlight relay, Eastern Beaver makes one. It won't fix the headlight problem, but prevents it from happening. One thing to check is the headlight switch, look for burnt contacts, often times you can clean these up and it will fix the headlight issue. A typical problem, it happened to me.
As far as the intermittent battery problem, I'm not sure, it may or may not be part of the headlight problem. As you may know stators are notorious for failing on these bikes, but being your seems to be intermittent is confusing.
2009 Wee Strom ABS (current)
1987 Harley FXR Low Rider Sport (current - with 206K miles)
2009 Aprilia Mana 850, 2006 SV650, 1984 Yamaha Virago 1000 (all sold)
Silver Strom Club Member #11
Wee Farkles: Russell Day Long Seat, Madstad with Moose Adventure Shield +4'', SWMotech Centerstand, 1'' up & back bar risers, Givi XS308 Tankbag, Aprilia mirrors, Framesliders, Fenda Extenda, Elka Shock.