It doesn’t sounds like this was ever a legal practice in any culture, past or present, although it does happen in China, and perhaps the government looks away.
The ‘whipping boy’ concept is interesting in that for a place in the royal court all someone has to do is take whatever punishment the prince is due. Assuming the prince isn’t running around murdering people this might not be a bad gig.
How did one become a “whipping boy”? Was it sort of something that hit you in the rear one day (pun intended) either as an opportunity or by force or coercion, or could you actually go out and proactively apply for a Royal Appointment to the post of Whipping Boy, go for an interview, take job placement exams, etc.?
How close in age did a whipping boy have to be to the real prince? E.g. could a 13 year old boy serve as the whipping boy of an 11 year old prince? How about a 14 year old, or a 9 year old? Too much difference to be considered legal?
Would it have been illegal to select a girl as a “whipping girl”, or was that something that was Just Not Done?