Easy solution is Applescript:

on run argv
  set layoutName to item 1 of argv
  tell application "System Events" to tell process "SystemUIServer"
    tell (1st menu bar item of menu bar 1 whose description is "text input") to {click, click (menu 1's menu item layoutName)}
  end tell
end run

save it as ‘change_input.scpt’ wherever you like. Now run it using:

osascript change_input.scpt "U.S."

or

osascript change_input.scpt "Dvorak"

or whatever layout you need.

Note, you need the inputs enabled and the input menu enabled for the menu bar.