2 of 2 replaced http://stackoverflow.com/ with https://stackoverflow.com/

As @LeeJoramo suggested, you can use Keyboard Maestro and some AppleScript to turn on the desired layout when switching to a certain app. For example, here's a KM macro that sets my keyboard layout to "Greek" when I switch to TextMate:

enter image description here

The script, borrowed from this StackOverflow answer:

tell application "System Events" to tell process "SystemUIServer"
    tell (menu bar item 1 of menu bar 1 whose description is "text input")
        tell menu 1
            click (first menu item whose title contains "Greek")
        end tell
    end tell
end tell