What @Ricko1966 said could be a possibility, I'd advise a second look over the wiring. Does the running lights also flicker off? But what @RustyPile said is also likely, not only at the headlight switch but also the dimmer wiring could be doing it. This is nothing to play with, if it's dead...