Sounds like Fungus Gnats.
here's an excerpt from a webpage that I found:
"Fungus Knats: In the soil, the immature, l/8 inch long maggots eat the roots. The old remedy was to soak the soil weekly, 3 times, with a solution of the chemical malathion. The new safe control is Gnatrol, a new formulation of Bacillus thuringiensis Israeliensis, which is the same ecologically safe material used for mosquito control in our swamps. "
I also found this one:
"Question: What are the little black gnats that fly out of my houseplants when I move them or water them?
Answer: Those are fungal gnats. They're more annoying than they are damaging. They are indicators of keeping your plants too wet. They develop in the algal scum that grows on top of wet soil, also on the walls of pots. Control them by (1) watering slightly less often, (2) replacing the top half-inch of potting soil with fresh soil and (3) drenching the soil with a houseplant insecticide."
And one more:
"Fungus Gnats. Adult fungus gnats are small flies that resemble mosquitoes and are grayish to black, 1/8 of an inch long, slender and delicate. Fungus gnats breed in moist areas that are high in organic matter. The larval stages feed on fungi. Large numbers may be found reproducing in potted houseplants. Adults are attracted to light and often gather in large numbers at windows. Proper water management is very important in fungus gnat control. Avoid overwatering and use sterile potting soil to prevent infestations. Insecticide applications may be necessary at times to control heavy infestations. The larvae are best controlled with soil drenches or granular insecticide formulations applied to the soil surface and watered in. Adults can be controlled with sprays or aerosols when they are observed."
It seems that I would get these bugs too in the terrarrium I have, and it would happen most often right after I watered it. It never got bad enough that I had to treat it though.
Hope that helps!