It's metaphorical, not literal. No physical action is involved, just verbal or written criticism or correction. The manager rapped him on the knuckles for his report's mistakes.
Pro Tip 2/3
Mild Criticism
The phrase implies a mild or moderate form of correction, rather than a severe punishment. She was rapped on the knuckles for forgetting to attach the document.
Pro Tip 3/3
Informal Setting
This phrase is often used in informal contexts among friends, family, or coworkers. I got rapped over the knuckles for being late to the lunch gathering.