The difference between the scenarios is not an abstract difference between nonkosher food and worms, but between cooked and uncooked food and food of the same type and food of different types.
First, taste only transfers if cooking occurs with heat higher than Yad Soledet Bo or one of the substances is "sharp" like an onion (neither worms nor lettuce have "sharp" taste). If the worm and lettuce were cooked together, the lettuce would be forbidden even after the worm was removed. If no cooking occurs, the lettuce is kosher and you only need to get rid of the worm. The cooked chicken has all received nonkosher taste and is forbidden.
The other difference is that the worm and lettuce are different types of food, while the types of chicken are the same type of food.
For a mixture of different substances, two standards decide whether the mixture is forbidden:
- Is the taste of the forbidden substance discernable?
- Is the proportion of the forbidden substances bigger than 1/60?
Poskim debate whether both criteria must be met to forbid the mixture or only one. If the worm is removed neither criterion is met and the lettuce is kosher.
The Chachamim and Rabbi Yehuda (Menachot 23a) debate the case of similar substances like chicken. Rabbi Yehuda forbids even the smallest amount, while the Chachamim allow the mixture to be eaten if the forbidden food is less than the permitted food (Batel B'rov). If the food is cooked, though, the whole mixture is forbidden according to all opinions because of taste transfer.
Edit. As commenters have noted, the worm could be considered harmful taste, which is permitted even after cooking (although the worm must be removed if it has not completely disintegrated). They also point out that I was acting under the assumption that the worm was greater than 1/60 of the lettuce which is usually incorrect.