It looks good to me.
You might think about renaming the $toggle Ssl variable to something like $forceSsl, since you're not really toggling anything (a toggle would turn it on if it's off and off if it's on).
Since it runs on every page load and has to be called uncached, you could speed it up slightly by getting the value of the TV this way:
$resourceId = $modx->resource->get('id');
$tvId = 12; /* Set to the ID of the TV */
/* Get the value of the modTemplateVarResource */
$query = $modx->newQuery('modTemplateVarResource', array(
'contentid' => $resourceId,
'tmplvarid' => $tvId,
));
$query->select('value');
$toggleSsl = $modx->getValue($query->prepare());
/* The rest of your code here */
Doing it this way avoids MODX having to get the TV object itself and avoids MODX calling the render method on the TV, since you don't need it rendered. This code assumes that the TV doesn't have a default value (it shouldn't) and you never use @INHERIT with it. If you want a default value, put it in the snippet at the end of the code above:
if (&toggleSsl === false) {
$toggleSsl = '0'; /* or $toggleSsl = '1' */
}