Give someone what for
To chastise or punish someone dates from 1873 according to the OED. It is thought to have arisen in informal speech in response to the question, “What was that for?” on being the recipient of chastisement, to which the punisher usually responds, “I’ll give you what for!” After which, the punishment might continue.