I wouldn't mind a built-in "Execute this command each time this profile is unloaded" option(actually mainly for when VoiceAttack shuts down to clean up anything left set or running), but that does not currently exist.
Now, you don't want to hard-code a list of games into on profile, but what you could do is have the game-specific profile set a variable with the game's process name, and have a command in your steam profile that runs on load to check for that process specifically.
That way, if you add a new game profile, you just have to add an on load command that sets the variable, and the command on the steam profile side takes care of the rest.