1979c20 is on the right track, has to be a wire issue. If it was me I would go to the tech section here and get the wiring diagrams for your truck, then trace the fuel circuit and headlight circuit ( you might want to try to see if other switches do it also ), it really sounds like to me that somehow you grounded/crossed the two circuits,and with out the truck running you turn on the headlights and "drain" the power from the fuel gauge circuit. Electrical issues can be a nightmare and a headache, but if you approach it with a plan and remember to take the simple steps first you should be able to trace the problem.
Good luck and keep up informed, welcome to the site also from California.