Your headlight bulb socket could be melted and the connector is intermittent causing the normal operating ESC control unit to switch back to the low beam.
There is a ceramic H4 bulb socket available for a replacement. Search the internet and this forum.