If you have two wheels of the same size, but you want to switch their hubs, say because you want to have a coaster hub instead of a five cog free wheel in a single speed conversion, here is what to do:
Tape the spokes on each rim so they can't shift anymore.
Unscrew the spokes either by hand or with a drill.
Give that rim a good cleaning.
Take apart the other rim in the same way.
Swap the hubs.
Put the wheels back together, tightening the spokes by hand and then true them.