If you want the line to ever execute, you'll need it ahead of Frostbolt.
And if it is ahead of Frostbolt, it can get stuck when you have no pet, and the pet is on cooldown.

I would think the best bet will be to include it early in the macro.
With a mod arguement, for summoning pet only if the mod key is used.
That or put it on its own button.