Those are fungus gnat larvae. I have only had them once so I dont a whole lot about treatment but i would assume that azatrol/
azamax would do the trick with the least harm to your plants. I saw them in cuts I had rooting and in a fit of rage I just tossed everything and started over (I had just got over root aphids and found these). I have seen
azamax/azatrol kill a lot of stuff with the only exeption being root aphids or hardcore mites.. With
azamax I believe they reccomend applying every third day for infestations and once a week or every other week for preventative. I have used it as often as every other day and the only problem I found was the plants started showing slight deficiencies from not getting nutrients with every watering which was an easy fix... I have also heard of people putting an inch or so of sand on top of their soil which will stop the adults from being able to fly out and eventually (since no more eggs are being laid) there will be no more gnats.
If you are going to keep them I would personally treat them BEFORE the transplant just because it would be a smaller containment area which would give you a better chance of killing the infestation. If you transplant first they would have more medium to occupy and hide in.