Energy conservation in a system of two bodies 
I have no idea why my previous post was marked as a homework question where the solution was clearly visible. I was asking to clear a concept of mine regarding system of bodies.
However,i will keep things to the point this time. The picture shows two bodies attached to a massless rod in a vertical plane and they can rotate about the topmost point. Suppose we give a velocity $v$ to the lower mass.When conserving energies, why is that the total potential and kinetic energies of the two bodies conserved and not individually? Like the equation was
$m_2gr+\frac{1}{2}m_1v_1^2+\frac{1}{2}m_2v_2^2=$ that of the final. Why couldn't we just equate $m_2gr+\frac{1}{2}m_2v_2^2$ or the same with $m_1$? If we consider any one of the masses and earth as the system and then conserve energy? No external force us acting on that system. Moreover, in the equation stated above,shouldn't there be a gravitational potential energy equal to $-\frac{Gm_1m_2}{r}$ included as well since there are two masses? Kindly clear my misconception. I don't get why the energy of the system of the two bodies and earth remain conserved but when considering individual masses, the energy doesn't remain conserved.
 A: Total mechanical energy (KE+PE) of a system is conserved if the sum of external forces acting on the system is zero. Consider the following systems:

*

*$m_1$ plus Earth

*$m_2$ plus Earth

*$m_1$ + $m_2$ + Earth

System (3) can be considered isolated since the force of gravity and the forces each mass exerts on the other are internal to the system. Thus for system (3) mechanical energy is conserved.
Systems (1) and (2) are not isolated. $m_2$ is an external force on system (1) and $m_1$ is and external force acting on system (2). Thus mechanical energy is not conserved for systems (1) and (2).
$m_1$  and $m_2$ alone are not isolated systems since they are each acted upon by the other and by the force of gravity.
Finally, the gravitational force between the two masses (and the associated potential energy) is an internal force of system (3) . In any event, the potential energy between, say, two 1 kg masses separated by 1 meter is on the order of 10$^{-10}$ Joule .

It seems that the only reason we are conserving energy as a whole is
due to the tension force.

Energy as a whole is always conserved when you consider both the defined "system" and its "surroundings", which together constitute the "universe".
The reason we are conserving energy in system (3) is because no net work is being done on/by the system with respect to its surroundings. When net work is done by or on a system energy is added to or removed from the system with respect to its surroundings.

I had decided that whenever I see more than one body, I will have to
conserve the total energy instead of considering the energy of
individual bodies.

It’s not how many bodies are involved. It’s whether or not they interact.  Suppose $m_1$ and $m_2$ in systems (1) and (2) above were not connected to each other by a rod. If the gravitational attraction between them is negligible (as in my example above) and they do not otherwise interact, then energy is conserved in each system.

So, that means if I just have some bodies spread, with no connection
between them, I can equate the initial and final energy of the
individual bodies instead of considering as a whole, right?

Correct. That’s what I just said.
Hope this helps.
A: Generally, only the total energy of an isolated system is conserved.
You write

No external force us acting on that system.

meaning the system of earth and one of the masses... But it is not true: the two bodies do interact with each other via a mechanical force - they pull the rope between them! Hence, Earth+$m_1$ is not an isolated system.
The contribution $- G m_1 m_2 /r$ to gravitational potential energy is simply so small that you can neglect it - for sure you don't expect to feel the gravitational attraction between two things hanging on a rope.
A: You choose the system.
Once this is done then internal and external forces need to be identified.
An internal force will always have a Newton's third law pair and an external force will not have a Newton third law pair.
System - masses $m_1$ alone.
The mass $m_1$ has no internal (Newton third law pair) forces acting and two external forces:
force on mass $m_1$ due to the massless rod and
force on mass $m_1$ due to the gravitational attraction of the Earth.
The kinetic energy of the system is not conserved.
System - masses $m_1,\, m_2$ alone.
Masses $m_1$ and $m_2$ act on each other via the massless rod so there are internal (Newton third law pair) forces:
force on mass $m_1$ due to rod and force on rod due to mass $m_1$ and
force on mass $m_2$ due to rod and force on rod due to mass $m_2$
and external forces:
gravitational force due to Earth on mass $m_1$ and
gravitational force due to Earth on mass $m_2$,
thus the mechanical energy of the system is not conserved.
System - masses $m_1,\, m_2$ and Earth.
Masses $m_1$ and $m_2$ act on each other via the massless rod and the masses and the Earth interact via the gravitational force so there are internal (Newton third law pair) forces:
force on mass $m_1$ due to rod and force on rod due to mass $m_1$,
force on mass $m_2$ due to rod and force on rod due to mass $m_2$,
gravitational force due to Earth on mass $m_1$ and gravitational force due to mass $m_1$ on Earth and
gravitational force due to Earth on mass $m_2$ and gravitational force due to mass $m_2$ on Earth,
As here are no external forces present, the mechanical energy of the system is conserved.
In general you need to identify external forces and torques acting on the system of your choice.
One other thing to note is that you cannot use the concept of gravitational potential energy unless you have a system with at least two masses present.
