Distinction should be made between the energy terms heat and work. Both represent energy in transition. Work is the transfer of energy resulting from a force acting through a distance. Heat is energy transferred as the result of a temperature difference. Neither heat nor work are thermodynamic properties of a system. Heat can be transferred into or out of a system and work can be done on or by a system, but a system cannot contain or store either heat or work. Heat into a system and work out of a system are considered positive quantities.
When a temperature difference exists across a boundary, the Second Law of Thermodynamics indicates the natural flow of energy is from the hotter body to the colder body. The Second Law of Thermodynamics denies the possibility of ever completely converting into work all the heat supplied to a system operating in a cycle. The Second Law of Thermodynamics, described by Max Planck in 1903, states that:
It is impossible to construct an engine that will work in a complete cycle and produce no other effect except the raising of a weight and the cooling of a reservoir.
The second law says that if you draw heat from a reservoir to raise a weight, lowering the weight will not generate enough heat to return the reservoir to its original temperature, and eventually the cycle will stop. If two blocks of metal at different temperatures are thermally insulated from their surroundings and are brought into contact with each other the heat will flow from the hotter to the colder. Eventually the two blocks will reach the same temperature, and heat transfer will cease. Energy has not been lost, but instead some energy has been transferred from one block to another.