Two manifestations of magnetic energy are compared: the magnetic energy of a current-bearing coil and that of an elementary magnet.
Incidentally: If a permanent magnet is heated above a critical temperature, it loses its magnetization. The magnetic energy is released as additional heat at this so-called Curie temperature.
Information and ideas:
A simple experiment on magnetization: If you pass a permanent magnet over an iron nail, it magnetizes the nail. What work has to be expended for this, apart from the friction work? Is the permanent magnet or its magnetic energy “used up" in the process?