Auto change keyboard layout based on application focus
If you go to System Preferences -> Language &amp; Text -> Input Sources, you should have the option to "Allow a different one for each document" under Input source options. 

The change is per document and not per application, but unless you change the setting for one document when you have several open you might not even notice the difference.