Once you have enough moisture in the headlamp it will condense out onto the coldest surface first. When the lamp heats the condensation goes back into the warmer air, which can hold more moisture.
You can use silica gel packets on a string through the lamphole if there is one, seal it up, to dry out the insides somewhat. Maybe a dry rag on a sick etc.
You can try using a dry gas, for example to replace the air in the headlamp to get better results.