An electron can move from one orbit to another, but only when the atom takes in or gives out electromagnetic radiation. When an atom absorbs electromagnetic radiation, an electron takes in the energy and moves to an orbit that is further from the nucleus. The electron needs exactly the right amount of energy to move between two particular orbits.
The reverse also happens. An electron in an outer orbit can fall to an orbit closer to the nucleus. When it does, the atom emits electromagnetic radiation, which carries away the energy the electron has lost.
So the rule is simple. Moving to an orbit further from the nucleus means absorption of radiation, and moving to an orbit closer to the nucleus means emission of radiation. If an electron absorbs enough energy, it can leave the atom altogether.