The headlight and tail light circuits will run through the headlight switch, but there should be a separate circuit for the brake lights. The most likely cause for intermittent operation of lights in general is bad grounds. There must be a clear path back to the battery for every circuit, and when one ground path is blocked by high resistance the circuit will look for another way to complete itself. Sometimes that turns another light off by the voltage looking for a path to ground through the filament of another bulb. It's not uncommon for one bad ground path to cause another light to go out when the brakes are applied, etc.
Start by cleaning all the bulb bases and sockets, and then make sure the bed and front fenders have good grounds back to the frame and/or engine. Good luck!
Jerry