The right way is to use an arbor press to press the axle out of the bearings. A full-service auto parts store or a machine shop should be able to do it properly. You/they should only apply force to the inner bearing race to avoid bearing damage so proper fixturing is essential when pressing the new ones on. Pounding is strongly discouraged!