Heating a magnet causes the electrons inside to spin and generally move to higher energy states, which makes them end up in a position that’s opposed to other electrons nearby. Because of this the electrons are no longer as well lined up, so the magnetism of the whole object decreases. Eventually whole regions of the magnet fail to be lined up properly and the magnet is demagnetized.
You can also remove the magnetic property of a magnet by placing it in a reversed magnetizing field. This will oppose the object’s magnetism. You can do this by passing an alternating current through a component of the magnet. This is how demagnetizing tools work.
Any amount of heat can cause a magnet to lose its magnetic properties. A smaller amount of heat, such as at room temperature, will have this effect over a much longer time period.