Conservation of Energy in a magnet

No, there is no need for the permanent magnets to lose any internal energy or strength when they are used to do work. Sometimes they may weaken but they don't have to.

The energy needed to do the work is extracted from the energy stored in the magnetic field (mostly outside the magnets), $\int B^2/2$, and if the magnets are brought to their original locations, the energy is returned to the magnetic field again. The process may be completely reversible and in most cases, it is.

Imagine two (thin) puck-shaped magnets with North at the upper side and South at the lower side. If you place them on top of each other, the magnetic field in the vicinity of the pucks is almost the same as the magnetic field from one puck – the same strength, the same total energy.

However, these two pucks attract because if you want to separate them in the vertical direction, you are increasing the energy. In particular, if you separate them by a distance much greater than the radius of the puck's base, the total magnetic field around the magnets will look like two copies of a singlet magnet's field and the energy doubles.

If the magnets are close, the magnetic energy is $E$; if they're very far in the vertical direction, it's $2E$. You may consider this position-dependent energy to be a form of potential energy (although there are some issues with this interpretation in the magnetic case when you consider more general configurations: in particular, a potential-energy description becomes impossible if you also include electric charges), potential energy that is analogous to the gravitational one. Gravitational potential energy may be used to do work but it may be restored if you do work on it (think about a water dam where water can be pumped up or down). Nothing intrinsic has to change about the objects (water) and the same is true for the magnets.

Let me mention that for a small magnet with magnetic moment $\vec m$ in a larger external magnetic field, the potential energy is simply $$ U = -\vec m\cdot \vec B $$ Independently of the magnetic field at other points, the potential energy is given simply by $\cos\theta$ from the relative orientation of the magnetic moment and the external magnetic field (times the product of absolute values of both of these vectors).


An easy way to see the answer is to switch the question from magnetic forces to gravitational forces.

When the Earth attracts a steel ball, energy is converted into for instance kinetic energy and heat. Does this imply that the Earth is depleted, making it weaker and weaker for each gravitational attraction performed?

Of course the Earth's gravity doesn't "run out" by attracting things. (It actually gets stronger!) You release energy by bringing two gravitating objects together, but that doesn't contradict energy conservation, because you need to spend the exact same amount of energy to pull them apart again. Same with magnets.