Surprisingly, most creatures already do this! Fats built up on the body contain Chemical potential energy, as does glucose molecules in cells. This definitely isn't storing lightning in your veins, but organic flesh isn't very good with electricity as we know it.
Fat itself contains around 9 calories per gram, which is about 37kJ of raw energy waiting to happen. 1 kilo of fat contains 37,656 kilojoules of energy. This is actually rather impressive, compared to our modern batteries, which usually contain around 360 - 900 kj/kg, human fat is a lot better at storing energy than a literal battery in your chest.
Comparison of Energy Densities
Storing "Pure" Energy
Energy isn't something that can really be pure, but it does have a lot of forms, the one you're probably thinking of when you say "Pure" energy is probably Electrical Energy.
There are two ways to go about doing this in a "Safe" way.
The first, is to store Electrical Potential Energy rather than the energy itself.
This means storing the means to generate electricity, rather then the pure electricity, like a traditional battery. If you want examples of how a creature can evolve this, look no further than the Electric Eel. It contains pairs of organs referred to as Electric Organs, which essentially uses ATP, which is cell energy, to generate electricity, much like a muscle does. In the eel, this produces either low or high voltage zaps, in this theoretical creature, it may be able to create a magnetic field. This is probably the best method, as it's the safest, and uses the body's already supple energy to charge.
The second is to actually store electricity itself in a highly conductive organ, preferably a 100% efficient conductor, surrounded tightly by insulation. Both of these factors are highly important, and are likely reasons that an organ like this wouldn't evolve. If the conductor isn't conductive enough, power will drain from the system slowly, and the organ will unnaturally heat up. If the insulator isn't effective, the power could leak, and potentially stop the creature's heart. This doesn't even go into the idea of how one would charge the battery.
Magnetic Field Control
Now, Magnetic Fields can't really be stopped, there's nothing really practical that can be done to reduce the passive magnetic field that organisms put out, but it's theoretically possible for a creature to create their own stronger magnetic field.
Electricity flowing through a wire (or a particularly conductive organ) will generate a magnetic field no matter what, which is why Magnetroception can be used to detective movement of living things, But if you want a particularly strong magnetic field, you'd need to move a lot of electricity through a small space, usually a coil; This is the concept of an Electromagnet.
If the creature can produce a sort of organic wire, probably from a mineral like iron, it would be possible to coil it up somewhere, and send power from the previously mentioned energy storage methods through it. This comes with many of the similar risks as the lightning box did, that is, energy leaks could stop the heart, or the tissue not being conductive enough wasting energy, but it is theoretically evolutionarily possible.
Evolution of a Magnet Organ.
For a creature to evolve something, it needs to be useful early in it's development; evolution isn't particular fast, and it does not favor the useless. But if the world this creature lives on is incredibly rich in a ferromagnetic mineral, so much so that most creatures are digesting it, it could be favourable for a creature to generate their own weak magnetic current, to pull food towards them, and that in the like, although this is a bit of a stretch.
It seems the most probable way for a creature to evolve this organ, is for it to first evolve the organ required for electrical production, probably to shock prey much like our eel friend, and then from there adapt it to magnetisation, for some unknown gain.
Citations provided where possible, much of this is speculation