umm, I'm not completely sure, but probably with a trigger. For my way, you'd need two seperate units though (one that can only harvest wood and one that can only harvest gold)
You'd need to make a trigger where the event was that a unit was given an order. The conditions would be that the order was to return gold; and that the unit given the order was equal to (gold harvesting unit). The actions would be to order (triggering unit) to return gold to (whatever building you want).
I didn't check to see the exact stuff you'd have to put into the trigger editor, just came up with it on the spot. It should work, but I'm not entirely sure, try it out and let me know