In most military commands, the chain of command IS that Troi, by virtue of being of higher rank, is in charge.
But Troi is just a shrink. Today, those would be of high rank because they are highly educated and deserve high pay, and high rank is the way to establish high pay. So the ship's surgeon or dentist might very well be a LtCmdr, but certainly couldn't override a Lieutenant's or an Ensign's decisions over the actual operating of the ship.
Troi would be out of the chain of command for another reason, too: she has the special power of declaring even a higher-ranking officer medically unfit to serve, so she must be discouraged from abusing that power to personal gain. Hardly in order to stop her from declaring the entire ship unfit and assuming total command herself - but it would already be a problem if she were told to do something and refused on grounds of the person giving the orders being "obviously distraught" and "not in control of his actions".
Basically, Ensign Ro would have to call LtCmdr Troi "Sir" (although she flat out refuses to do even that much in the episode!), but wouldn't have to take orders from a shrink. She agrees to do so, though, because of O'Brien's authority in the situation.