You can check the exit status of any critical command in your heredoc and exit the ssh with an error - then check the ssh exit status to exit your script
The commands in the here decument are executed by a remote shell. You need to pass in set -o errexit inside the here document in order for it to be visible there; it is entirely separate from the shell which runs the ssh command.