Assigning shortcuts to particular keyboard layouts
There is a solution that has been vetted on 10.5 through 10.7 and has both a source code example as well as a link to a direct download of a program to do this sort of switching.

https://discussions.apple.com/thread/4032238

You'll need Xcode or to use the compiled program to test if this works for you. And always, use caution when downloading software from the internet. Most people are nice and good, but sometimes it's hard to know what you're running.