Experts and BHG readers answer.
Green Worms on Basil
The pests you are describing are leaf miners. They are larvae of tiny flies or moths. The adult insects lay eggs on the plants and the larvae tunnel into the leaves for feeding. Surface sprays don't deter them, because they are safe in their tunnels. You don't want to apply any chemicals that are absorbed by the leaves, because you don't want treated leaves in your pesto. The best defense is good prevention. Discourage the breeding adults with insecticidal soap sprays, and good sanitation. Reduce the hiding places for the adults by keeping leaf litter picked up, and removing infested leaves. You can also screen the basil plants with light-weight floating row cover. Sunlight will get through, but the insects won't.