I'm not sure you can assist one of those pets directly. For instance as a hunter I can assist my own pet with /assist [target=pet], or use /assist focus having focused my pet prior to that. (I also use clique to automatically assist the target on ctrl+right click.)

But I think mage pets are different from lock or hunter pets, for instance they don't appear listed in party pets unit frames. So it might be only able to assist from a target or with a focus. Assuming you use the latter it would be something like:
Code:
#showtooltip
/assist focus
/cast <spell>
I know for a fact you would be unable to follow the pet, as you can only follow other players of the same faction.

The best bet is to have the pet work as pretty much a free agent, so except for very occasionally you let the pet assist you rather than the other way round.