This may be one of the most misunderstood aspects of aerial combat. Once it is broken down to the basics, it is very simple. Think of energy as your household budget. Speed is the cash you have in your hand and you can spend it right now. Altitude is the bank, the place that you store extra cash. Your engine is your paycheck. Any extra energy you have after you pay the maintenance bills of drag can be converted into speed or banked as altitude.
The sum of all three items, speed, altitude and engine reserve, is your total energy budget. This represents your ability to perform maneuvers. When your total energy state is zero, you are on the ground - either in a smoking hole or parked on a runway.

Relative energy is the comparison of your total energy status to the enemy’s total energy status. This is a very rough gauge of which pilot has the true advantage in an engagement. Relative energy is never constant. Each pilot is using his energy for different maneuvers and changes in altitude and speed. An advantage in relative energy allows more options in a fight than a disadvantage. With the advantage you can take the initiative rather than only being able to react to your opponent’s actions. Simply having an advantage in energy is not going to win a fight but it is a starting point.

How do you gain energy? Using engine power to gain speed or altitude is the only way to increase your total available energy. Increasing engine power output will increase your speed. This is limited because you can not continually increase speed. A drag imposed limit will eventually be reached and speed can not be increased without another power increase or worse, a loss of altitude. Altitude is more important than speed in most cases. Altitude gives you the advantage of position as well as energy. Climb whenever possible, within the constraints of your mission. Even if you are only climbing at a rate of 100 feet per minute over a ten minute period you have gained a 1,000 feet of reserve to work with.

What costs you energy? Any change of direction or attitude costs energy. The single biggest waste of energy by new pilots is using extra Gs. Sure it is fun to make fast turns in a fighter, but when you do not have to maneuver hard any extra Gs cost energy. The more Gs you use the greater the loss. Try this simple test - get in your favorite plane and get settled in level flight at cruise speed. Then make what you think is a ‘normal’ turn. Look at the G-meter. Odds are that you are pulling 2 or more Gs in that turn. Now check your airspeed and altitude after the turn. The loss of either shows you how and where you can easily lose energy. 
Pulling extra Gs is probably the single greatest cause for energy lose. Losing unnecessary altitude is the second. Strive to use shallower nose down maneuvers whenever possible. Altitude you do not lose will not cost you anything to regain.
Smaller things like over controlling or imprecise flight cost energy as well as time. Leaving flaps down longer than they are needed. Flying out of trim or skidding/slipping in turns all cost energy through increased drag. 

You can see that there are many more ways to lose energy than there are to gain it back.

Converting altitude to speed. Diving will convert altitude to speed but there are limits when doing this. Ease the stick forward to get your G-meter on zero Gs - free fall. This converts altitude to speed in the most efficient manner. Diving faster than you can fall is wasting altitude. 
Though the zero G dive is the fastest way to convert altitude to speed, it can be excessive once the dive angle reaches 30 to 45 degrees. This is because of the trade off between energy gained and the loss of energy of pulling out of the dive. Loss of position is another disadvantage of diving too steeply. 
There is one more limitation on converting altitude to speed. Your aircraft will have some maximum safe speed, beyond that speed there is a danger of ripping parts off the aircraft. Continuing a dive once this speed is reached is wasting altitude, and energy - the aircraft simply can not safely go any faster.

The reverse is true when converting speed to altitude. The best way is to point the nose straight up and get the aircraft to a zero G state. This way you are ‘falling’ straight up. The absolute limit is when the aircraft reaches zero airspeed. Although this will get some extra altitude, it will be lost as the aircraft drops until it regains flight speed. Ease out of the climb when the aircraft reaches a minimum maneuvering speed.

In both climbs and dives reaching a zero G state is important for this reason - even at 1 G the wings are working to support the weight of the aircraft that takes energy. When that energy bill has been removed, the energy used to produce that lift is now being used to speed the dive or gain altitude.