Create an Event on the event layer and set the trigger to Parallel process and DO NOT set a sprite or graphic for this page of the event, use the conditional branch event and go to the 2nd page and set it so that it reads if Actor: Mage is in party then turn on Local Switch A If not -nothing-. It should look like this:
@> Conditional Branch: [Mage] is In the Party
@> Control Self Switch: A =ON
@>
: Else
@>
: End
Then create a second page on the event and set the graphic of the mage here along with whatever you want him to say, so whenever he IS in the party he will appear in the castle and whenever he isn't he won't.
If you want him to go away and do a quest, well you should try and figure out that yourself, because I don't know what you want him or her to do.