No, it is not always necessary for two objects to be in contact with each other for the application of force between them. Force can also act without any direct contact between the objects.
Such forces are known as non-contact forces.
Gravitational, magnetic and electrostatic force are examples of non-contact force.
Gravitational force: The attractive force of the earth which acts upon all the objects is known as the force of gravity or just gravity.
Electrostatic force: The force exerted by a charged body on another charged or uncharged body is known as electrostatic force.
Magnetic force: The force exerted between a magnet and other magnet or magnetic material is known as magnetic force.