Can an undead commanded by animate or command undead be told to follow someone else's orders?
Animate Dead: No.
The ability to command undead with Animate Dead is very limited. The rules state:
The undead can be made to follow you [i.e., the caster], or they can be made to remain in an area and attack any creature (or just a specific kind of creature) entering the place... The undead you create remain under your control indefinitely. [Emphasis added]
Basically you, the caster--and only you, the caster--can tell them to either follow you or remain where they are. You cannot tell them to go somewhere without you. In addition, you can order them to attack specific types of creatures. You cannot order them to do things besides moving and attacking--like cleaning up a mess or pitching a tent and starting a camp fire. Further, the limit on their movements is to stay still or follow you, the caster, period.
Now with some clever programming and GM consent, you could give another character some control over the undead's actions. For instance, you could command the undead to attack anyone that another character points at. After all, a creature so designated by a specific character could arguably be a "specific kind" of creature. That would be at the GM's discretion, though. A GM could interpret "specific kind" to mean a species, or a member of a readily identifiable group (like an evil acolyte in the evil temple's uniform). But even if the GM allowed it, the undead would still be following your orders, not the other character's.
Command Undead: Yes, but the undead would have to be intelligent and orders the other character could give would be limited.
First, the rules are clear:
When you control a mindless being, you can communicate only basic commands, such as "come here," "go there," "fight," "stand still," and so on. Nonintelligent undead won't resist suicidal or obviously harmful orders.
So with nonintelligent undead, such as skeletons or zombies, an order to follow someone else's order is simply too complicated.
As for intelligent undead, the rules also state:
This spell allows you a degree of control over an undead creature. If the subject is intelligent, it perceives your words and actions favorably (treat its attitude as friendly). It will not attack you while the spell lasts. You can give the subject orders, but you must win an opposed Charisma check to convince it to do anything it wouldn't ordinarily do. Retries are not allowed.
The fact that you can give the undead orders means you can order the undead to obey another character; however, you would need to make an opposed Charisma check (because obeying that other character is certainly not something the undead would "ordinarily do"). Then, if command is successfully given to the other character, the limitations of not being the spellcaster would apply to the that character and any of his orders.
The spell's rules state that the caster's words and actions are seen in a favorable light and the caster may convince the undead to do something it would not "ordinarily do" by succeeding at an opposed charisma check. The character given secondary command does not have his words and actions viewed in a favorable light and does not have the ability to convince the undead to do things it would not ordinarily do. Therefore, he may only order the undead to do things that it would ordinarily do, and the undead would obey in an effort to fulfill the caster's command of obedience. So given secondary command of a ghoul, another character could order it to devour some corpses or drag a body off to its lair (things it would ordinarily do), but he couldn't get it to follow him or fight a vampire or go out in daylight. These are things a ghoul would not ordinarily do and the character with secondary command does not have the magical effect necessary to convince it to do so anyway.