It would be worth having a good look at all connections, including the ammeter, in the headlamp shell as, electrically speaking, that is a very busy place. However, your problem sounds more like a charging supply current issue related to the alternator or regulator/rectifier, as the meter flips from normal charging to battery draining rather than from normal charging to a no-charging condition - as you might expect from an intermittent ammeter to battery connection.