Assuming you're talking about outside trim (brick mold, sill, etc.) you're best off with composite (PVC/plastic) trim. If it's inside, you need to figure out where the water is getting in and address that situation. Then replace with new wood trim.
If you can read this, thank a teacher. If you can read this in English, thank a soldier. Support our troops.
I should have specified that the rotten trim is outside. Things are fine on the inside. So the issue is whether we should stay with wood or switch to metal. I understand metal trim lasts longer and is virtually maintenance free.