The same way they do with all other work in space
Working in a zero g environment represents special challenges, no matter what you are doing. Even something as simple as turning a handle that offers resistance can be a major challenge if you do not know what you are doing.
During the american Gemini program, a stepping-stone on the way to fulfilling Kennedy's promise of putting a man on the Moon before the end of the 1960's, one of the problems that had to be solved was that of how to perform an EVA: extra vehicular activity and perform actual work in a weightless environment. And the first attempt at that nearly ended really badly. Eugene Cernan got so utterly exhausted by trying to work in zero g that for a moment, Thomas Stafford thought Cernan might not get back into the spacecraft again. Luckily things worked out.
NASA solved this by working out methods on how to do work in weightlessness, and by instituting training for it.
"Buzz" Aldrin practicing working in weightlessness (Source)
The most obvious result of this was: make sure there are hand-holds, restraints and/or foot-loops. If you are applying force with one part of your body, make sure that you can anchor another part of your body to the space-craft to provide a counter-force.
Later on, when the concept of space stations came about, it was quickly realized that fluids present a bit of a hassle. And again: they solved the problem. The obvious solution to making sure fluids do not float about in your weightless environment is to make sure they do not get out in the first place. And when fluids are unavoidably expected to come out, you contain them, simply by encasing your work place in a fluid-proof "bubble" and/or make sure you have nothing that reacts badly to fluids in that space.
Administrating corporal punishment would be no different in that regard: it is a work task that is expected to be performed, so people would get trained in how to do it.
- Flogging, whipping and caning are the manual application of force.
Hence: allow the one that is administrating the punishment something to anchor themselves to the spacecraft.
Also: preferably you want to do this in a splash-proofed room. Then it does not matter if there is the occasional blood-splatter, or the involuntary evacuation of bowels, bladder or belly. Diapers may be used to lessen the mess.
- Amputation, drawing, quartering and flaying is surgery.
This too might get messy, so do it in a room where you can be messy without anything getting damaged. Tourniquets can be used to stem blood flow; suction pumps can be used to catch errant fluid; washable walls and having nothing all too sensitive to fluids in the room will solve the issue.