It's "slang", first recorded by OED 1873 Routledge's Yng.Gentl. Mag. Feb. 137/1 It'll give you what for if it touches your lips., with the definition to give (one) what for = to inflict severe pain or chastisement. More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.