Pests (foes) by our definition are organisms that are harmful to us or can cause damages to our properties. This also includes those that annoy us.
Beneficials (friends), on the other hand, are organisms that give benefits to us for example assisting pollination of plants, killing pests and so on.
By looking at the definitions above, we think that it is a straightforward matter. However in actual situation, it is not. Pests and Beneficials are sometimes separated by a thin shear layer.
These are few examples.
Termites are helping to decay organic materials in the forest (friend) but when we convert the forest to become residential or commercial areas, they become pests.
Honey bees produce honey and pollinate flowers (friend), but their sting could be deadly to humans (foe). So, when you are consuming honey or fruits, they are beneficial. However, if they build their nests in your compound, they are pests.
King Cobra was introduced by the British to control rats in the plantations (friend). With many of plantations have already been turned into housing estates, you probably would not want to see them on your door steps (foe).
From these examples, it is clearly shown that definitions are always made to our convenience.
By the way, if we do not like some human beings, for example some leaders or politicians, we also consider them as pests!