When hammer is hit on the metal there is friction between the hammer and the molecules of the metal (at their point of contact) and also the energy is transferred to the metal by the force applied. This sets the molecules of the metal in vibration and increases the temperature of the surface.
The force that we apply on the hammer is transferred to the metal, which causes vibrations and eventually increases the temperature of the metal.