The fungus gnat larvae live in the soil and are a clear indication that the soil you used was not sterile as it should have been. The larvae depend on damp soil in the upper layer of the soil in order to survive. The best antidote is to allow the soil to dry out as much as possible - just short of the plant's wilting.
Replacing the soil is one way to eliminate the larvae (as long as you don't use more contaminated soil), but the process may kill the seedling as its roots are fragile and easily damaged by repotting.
I suggest removing all soil from the surface that is not in immediate contact with the roots. That excess soil will harbor many of the larvae and removing it will allow the soil in the root zone dry out more readily.
When you do water, add just enough so that the soil is quite dry again in a week or less. Warm temps and lots of sunlight will help.
The winged adults have a lifespan of about a week, so no need to treat them. It is the larvae that need to be eradicated.