We worked on different magnetic molecules containing 3d and 4f magnetic centers. Their growth on metallic surfaces, topographies, spin states, magnetic properties and electron transport were locally investigated by using scanning tunneling microscopy (STM) at temperatures down to 30mK. The main achievement of this dissertation reveals the abrupt switching of crystal fields during formation of molecular contacts.