In early modern Europe, it was common for tutors to whip their students as a form of punishment. However, some historians believe that when it was time for a prince to receive punishment from his tutor, a "whipping boy" was punished instead.
A whipping boy was a student taught by the tutor as well, alongside the prince. When the prince misbehaved, the whipping boy "received corporal punishment for the prince's transgressions in his presence. The prince was not punished himself because his royal status exceeded that of his tutor; seeing a friend punished would provide an equivalent motivation not to repeat the offence. An archaic proverb which captures a similar idea is "to beat a dog before a lion." (Wikipedia)
I was imagining a leather whip being used to inflict the punishment until I saw the illustration below. The "whip" being held by the tutor looks more like a creepy bundle of twigs, or a witch's broom.