It happens to me on my HTC Thunderbolt too. It seems to be a reported android bug -- see Issue 16667 - android - Notifications are played through external speaker when headphones are plugged in - Android - An Open Handset Alliance Project - Google Project Hosting
-- but no word on when it would be fixed.
Does anyone know of an app that would fix it?
I know Cyanogenmod fixed it for the original Droid (which I had before the thunderbolt), but its still in alpha for the Thunderbolt with some issues, so I'm not ready to jump to it yet.