We do not really know for sure where or when the story is set -- the author does not come straight out and tell us. But from things in the story, we can be pretty sure that the story is set sometime around the 18th century. There are castles and royalty (and whipping boys). There are highwaymen and men wearing powdered wigs. All of this implies when the story is set.
It also seems that the story is set in Europe somewhere because of details like the dogs that fight rats and the dancing bear. Both of these were popular kinds of entertainment in Europe.
"The Whipping Boy" is the story of Prince Brat and Jeremy, who is hired to be his whipping boy. Whenever Prince Brat misbehaves, Jeremy gets whipped. Some of the different things in the story that give the reader a visual of the time and setting are men and women wearing powdered wigs. The trend of wearing wigs started with King Louis XIII. Around the 1600's wearing wigs was popular in Versailles. However, it was in the 18th century when powdered wigs were most popular in England. Based on this information the era seems to be the 18th century.
The palace has a main hall with royalty. This gives the reader that the setting is a castle. The other setting in the story is the forest which has fog and pines.
Other than these details the book has no specific location.