Fungus gnats are small flying insects about the size of a fruit fly. In the interest of full disclousure they are almost impossible to keep out the the tropical plant and bonsai supply chain. Fungus gnats are pretty much everywhere and the eggs can lay dormant until ideal conditions trigger hatching.
While they are an unattractive nuisance, they are basically harmless unless they they are left untreated for a long time, in which case they can attack the roots, but the larval stage usually lives on fungus and other oganic matter that is naturally found in the soil. Having said that, they won't go away on their own, so its useful to understand a little more about their lifecycle which typically lasts about a month.
Under good conditions (moist to wet soil near the surface of the pot) eggs will hatch in less than a week and the larva will feed on organic material in the soil just under the surface. After about two weeks the larva will pupate and emerge as the little fying adults.
Fungus gnats are not strong flyers. Most will lay their eggs in the same pot they grew up in and they tend to spend a lot of time walking around versus flying, but when they do appear it is not unusual to see a lot of them. Sadly this tends to completely freak out the more bug adverse people.
What to do about Fungus Gnats
1- Move the pot away from your other plants.
2- Remove the stones on the top of the soil and set them aside for later.
3- Allow the top inch of soil to dry out. This makes that soil a bad environment for eggs and the larva. Keep a close watch on the moisture level at the bottom of the pot and for the next two-three weeks bottom water your tree.
4- Use yellow sticky traps to get rid of the adults. If just out for a stroll on the pot rim or table top, they're also easy to kill. (It helps that they're so small.)
5- Once you dont see any more adults, keep the tree on the dry side and isolated for another two weeks.
6- Replace the stones and be sure not to overwater your tree as wet soil will attract fungus gnats and constantly wet soil will weaken the tree and that will attract all kinds of trouble.
Fungus Gnats a Bonsai Nuisance