In the mid-seventeenth century, young princes and aristocrats were sent off to school with a young servant who would attend classes and receive an education while also attending to his master’s needs.
If the master found himself in trouble, the servant would take the punishment for him, even if it were a whipping.
He was his master’s “whipping boy.”
Someone who continually takes the fall for someone else is called “whipping boy”.