It's called tinnitus, and it can be caused by any number of things. The most common culprit is usually damage done to the tiny hairs in your hears from listening to loud music or being in an area with a lot of noise (construction sites, for instance) or an ear infection. In rarer cases, it can also be caused by certain drugs (Aspirin, for instance, has been known to cause ringing in the ears, especially in cases of overdose), antibiotics, diuretics, etc., and is also tied to head injuries and certain physical or psychological illnesses. A lot of people will experience minor tinnitus at some point in their life -- it's not uncommon to hear a ringing or buzzing sound in your ears if you're in a very quiet room -- and it usually clears up on its own. However, if the ringing is excessively loud, seems to drown out other sounds, is accompanied by other symptoms or doesn't go away after a couple days, it would probably be a good idea to speak with a doctor.
Plus I've had tinnitus for years.