As far as I know from physics lessons I got at school, electrons go up to higher energy levels when they capture a photon. But, once an electron is at a given level, what makes it go down to a lower level and emit a photon? Is there a constant time during which an electron is able to stick at a level, and then jump to a lower level? I mean, I know electrons tend to reach low energy levels, but can you describe this process? Put in other words, how does an electron "know" there are lower energy levels and when does an electron choose to lose energy?
The electron itself doesn't "know". The entire system "knows" what its own energy levels are. That is, the system can make transitions only to states that exist. Don't think of the electron, think of the entire system that contains the electron.
The system will stay at the excited level for some period of time depending on the strength of the coupling between the system and the electromagnetic field, and the intensity of the field. Stronger coupling means shorter lifetime. And stronger field means shorter lifetime. This last effect is stimulated emission.
There is never a situation where the field has no intensity. The ground state of the electromagnetic field has "zero-point fluctuations", required by the uncertainty principle. No energy can be extracted from the field in the ground state, so it behaves like zero intensity. But the zero-point field can induce transitions in an atom just as in stimulated emission. This is the origin of spontaneous emission, the process by which an isolated excited system makes transitions to lower energy states.