If you've noticed a lot of small black flies around they'll be fungus gnat larvae.
I had them a couple of years ago when I repotted using cheap supermarket compost that had eggs in it.
Check the top of the compost and see if there are any little flies crawling around.
The larvae live off the compost and in the worst case eat away at the roots of the plant. The mature fly leaves the pot, mates, and then lays it's eggs in the compost again. And so on and so on...
If you have got them, the good news is they're easier to get rid of from chilli plants as the flies like the compost wet and chilli plants don't.
Get rid of any larvae you can see, then put a layer of sand on the top of the compost. When you water the plant the sand should dry out quickly. Avoid watering too heavily. When the flies have left the pot they won't return to lay their eggs as it's too dry for them now. (The dry sand puts them off apparently)
It takes a couple of weeks or so until the plant's all clear.