Oscillation Basics
One of the most commonly used oscillators is the pendulum of a clock. If you push on a pendulum to start it swinging, it will oscillate at some frequency — it will swing back and forth a certain number of times per second. The length of the pendulum is the main thing that controls the frequency.
For something to oscillate, energy needs to move back and forth between two forms. For example, in a pendulum, energy moves between potential energy and kinetic energy. When the pendulum is at one end of its travel, its energy is all potential energy and it is ready to fall. When the pendulum is in the middle of its cycle, all of its potential energy turns into kinetic energy and the pendulum is moving as fast as it can. As the pendulum moves toward the other end of its swing, all the kinetic energy turns back into potential energy. This movement of energy between the two forms is what causes the oscillation.
Eventually, any physical oscillator stops moving because of friction. To keep it going, you have to add a little bit of energy on each cycle. In a pendulum clock, the energy that keeps the pendulum moving comes from the spring. The pendulum gets a little push on each stroke to make up for the energy it loses to friction. See How Pendulum Clocks Work for details.
An electronic oscillator works on the same principle.
For more detail: How Oscillators Work