Ultimate Campaign gives us more info on who does control companions, pets, eidolons and cohorts, and the possible problems when either the PC or GM are controlling them.
Ultimately, the GM has control of all NPCs, that means that any character that a player doesn't control, is controlled by the GM, but there are a few exceptions, such as teaching an animal companion a trick so you can give it specific orders, but see all details bellow:
How a companion works depends on the campaign as well as the companion's nature, intelligence, and abilities. In some cases, the rules do not specify whether you or the GM controls the companion. If you're entirely in control, the companion acts like a subsidiary PC, doing exactly what you want just like a true PC. If the GM is control, you can make suggestions or attempt to influence the companion, but the GM determines whether the creature is willing or able to attempt what you want.
Aspects of Control
Whether you or the GM controls a particular companion depends largely on the creature's intelligence and level of independence from you.
Nonsentient Companions: a nonsentient companion (one with animal-level intelligence) is loyal to you in the way a well-trained dog is—the creature is conditioned to obey your commands, but its behavior is limited by its intelligence and it can't make altruistic moral decisions—such as nobly sacrificing itself to save another. Animal companions, cavalier mounts, and purchased creatures (such as common horses and guard dogs) fall into this category. In general they're GM-controlled companions. You can direct them using the Handle Animal skill, but their specific behavior is up to the GM.
Sentient Companions: a sentient companion (a creature that can understand language and has an Intelligence score of at least 3) is considered your ally and obeys your suggestions and orders to the best of its ability. It won't necessarily blindly follow a suicidal order, but it has your interests at heart and does what it can to keep you alive. Paladin bonded mounts, familiars, and cohorts fall into this category, and are usually player-controlled companions.
Eidolons: Outside the linear obedience and intelligence scale of sentient and nonsentient companions are eidolons: intelligent entities magically bound to you. Whether you wish to roleplay this relationship as friendly or coerced, the eidolon is inclined to obey you unless you give a command only to spite it. An eidolon would obey a cruel summoner's order to save a child from a burning building, knowing that at worst the fire damage would temporarily banish it, but it wouldn't stand in a bonfire just because the summoner said to. An eidolon is normally a player-controlled companion, but the GM can have the eidolon refuse extreme orders that would cause it to suffer needlessly.
Magical Control: Charm person, dominate person, and similar effects turn an NPC into a companion for a limited time. Most charm-like effects make the target friendly to you—the target has to follow your requests only if they're reasonable, and has its own ideas about what is reasonable. For example, few creatures consider "hand over all your valuables" or "let me put these manacles on you" a reasonable request from a friend. You might have to use Diplomacy or Intimidate checks to influence a charmed ally, and the GM has the final say as to what happens. Though the target of a charm effect considers you a friend, it probably feels indifferent at best toward the other PCs and won't listen to requests from them. a creature under a dominate effect is more of a puppet, and you can force it to do anything that isn't suicidal or otherwise against its well-being. Treat it as player-controlled, with the GM making its saving throws to resist inappropriate commands.
Common Exceptions: Some companions are exceptions, such as an intelligent companion who doesn't bear exceptional loyalty toward you (for example, a hired guard), a weaker minion who is loyal to you but lacks the abilities or resources to assist in adventuring tasks, and a called outsider (such as from planar ally) who agrees to a specific service but still has a sense of self-preservation. You can use Bluff, Diplomacy, and Intimidate to influence such companions, but the GM is the final arbiter of their actions. For example, a PC might use threats to convince a caravan guard to hold back an ogre for a few rounds or to prevent her zealous followers from attacking a rival adventurer, but the GM makes the decision whether the guard runs away after getting hit once or the followers attack when provoked.
The GM may deviate from the above suggestions, such as allowing a druid to control an animal companion directly, creating a more equivalent or even antagonistic relationship between a summoner and an eidolon, or roleplaying a mentoring relationship between a veteran warhorse and the young paladin who inherited his loyalty. Before you create a character with a companion creature (or decide to add a companion in play), the GM should explain to everyone how much influence you and the GM each have over the creature's actions. That way, everyone is fully informed about all aspects of dealing with the companion.
The specifics of controlling a companion vary for different campaigns. a gritty campaign where animal companions can't do anything that real animals can't do forces the GM to act as a check against you pushing the bounds of creativity. a high-fantasy game where familiars are nearly as important to the storyline as the PCs—or are played as near-PCs by other players—is a very different feel and can create interesting roleplaying opportunities.
An evil campaign where companions are unwilling slaves of the PCs creates a dynamic where the PCs are trying to exploit them as much as possible—perhaps even sacrificing and replacing them as needed—and treat them more like living tools than reluctant allies.
Issues of Control
The GM should keep in mind several factors when it comes to companions, whether handling them as suggested above or altering the balance to give you more or less control.
Ease of Play: Changing who controls a companion can make the game easier or harder for the GM. Controlling a cohort in combat is one more complex thing for the GM to deal with. The GM must keep track of a cohort's tactics and motivations and how those affect it in combat while keeping her own knowledge of the monsters separate from the cohort's knowledge; otherwise, the cohort will outshine the PCs with superior tactics. Giving you control over these decisions (while still allowing the GM to veto certain actions) alleviates some of the burden and allows you to plan interesting tactics between yourself and your cohort, much as you would have mastered during times you trained together.
Conversely, giving a player full control over the actions of two characters can slow down the game. If you're prone to choice paralysis, playing two turns every round can drag the game to a halt. If this is a problem, the GM should suggest that another player help run the companion or ask you to give up the companion and alter yourself to compensate (such as by choosing a different feat in place of Leadership, taking a domain instead of a druid animal companion, or selecting the "companions" option for a ranger's hunter's bond ability instead of an animal).
Game Balance: Even a simple change like allowing players to directly control companions has repercussions in the game mechanics. For example, if a druid has complete control over an animal companion, there's no reason for her to put ranks in Handle Animal, freeing up those ranks for other valuable skills like Perception. If a wizard with a guard dog doesn't have to use a move action to make a Handle Animal check to have the dog attack, he has a full set of actions each round and a minion creature that doesn't require investing any extra time to "summon" it. If companion animals don't have to know specific tricks, the PC can use any animal like an ally and plan strategies (like flanking) as if the animal were much smarter than it actually is.
With intelligent companions such as cohorts, giving you full control means you're controlling two characters and can take twice as many actions as the other players. The GM can create a middle ground, such as requiring you to put ranks in Handle Animal but not requiring you to make checks, or reducing the action needed to command an animal, but these decisions should be made before the companion joins the group.
Sharing Information: Whenever you control multiple creatures, there are issues of sharing information between you and your companions. Some companions have special abilities that facilitate this sort of communication, such as a familiar's empathic link or an eidolon's bond senses ability, but most companions are limited to what they can observe with their own senses. For example, if a wizard using see invisibility knows there is an invisible rogue across the room, he can't just direct his guard dog to attack the rogue; he has to use the seek command to move the dog to the general area of the rogue, and even then he can't use the attack command to attack the rogue because the rogue isn't an "apparent enemy." If the GM allows the wizard to make the dog fight the invisible rogue, that makes the animal much more versatile than normal, and also devalues the special nature of a true empathic or telepathic bond with a companion. If the dog is allowed to work outside the PC's line of sight, it devalues abilities such as a wizard's ability to scry on his familiar. Of course, intelligent companions using speech can bypass some of these limitations (such as telling a cohort there's an invisible rogue in the corner).
This information is free to read at the SRD: