Save this as “ssh” somewhere on your $PATH ahead of /usr/bin/ssh and make it executable
#!/bin/sh
HOSTNAME=$(echo $@ | sed 's/.*@//')
set_theme () {
    osascript -e "tell application \"Terminal\" to set current settings of first window to settings set \"$1\""
}
on_exit () {
    set_theme "Solarized Light"
}
trap on_exit EXIT
case $HOSTNAME in
  # These all do the same thing but we could have different themes for different locations
  hb|pd|decksite) set_theme "Solarized Dark" ;;
  *) set_theme "Solarized Dark" ;;
esac
/usr/bin/ssh "$@"
	