Demagnetizing metal is done by displacing the dipoles that give it the magnetic qualities. This can be done by hitting the metal with a hammer once it's aligned correctly and heating it above its curie temperature.
The simplest of these is by placing the metal in such a manner that the north and south poles face an east-west direction. The metal is then hit multiple times with a hammer and then assessed again for magnetism. The logic behind this is that the action of hitting the metal makes the dipoles more disorganized, especially when the piece of metal is not aligned in a north-south orientation.
Another way to demagnetize metal is by heating the piece of metal to just above its Curie temperature, which is the temperature at which the dipoles are most mobile, without having to melt the metal. Once this is done, the piece of metal is once again placed in an east-west orientation and then hit lightly multiple times. Heating the metal before hitting it makes it easier to displace the dipoles, meaning that the demagnetization is likely to be more effective. Before doing this, however, it is important to determine the Curie point of the metal in order to know just how much to heat it.