The only time Spock was ever in command of the Enterprise was in TWOK and even then, Kirk was still his superior officer, Spock was an instructor and Captain of a training ship, Kirk obviously oversaw the training of Cadets and was no doubt responsible for evaluation of their instructors (hence "I assume your loitering around here to learn what efficiency rating I give your Cadets")
MA obviously has this wrong, Spock has never given Kirk orders...unless you include Star Trek XI, which is set within an alternate universe to the main series
Post TVH, Kirk and Spock both share the same rank (its interesting because in contemporary militaries, if you recieve a demotion, then the people who you then share a rank with are counted as your superiors, as a consequence of demotion, if this was to be applied to Starfleet, then heck, Kirk would have to take orders from Scotty :P) However this isn't the case as Kirk is in command of the Ent-A, he is Spock, et al's superior officer, despite sharing the same rank with two of his officers, therefore they have to take orders from him and the chain of command works to this system as well
For better clarification, check out DS9, where Dax is in command of the Defiant on occasions, despite being outranked, even by Worf (who is not only a Command Division Officer, but also was promoted to Lt Commander some time before Jadzia) again even as a Lt Commander, Jadzia was called Captain while commanding the ship (as naval tradition dictates)
Another example is VOY, where Ensign Harry Kim, despite being outranked by several officers, such as Lt Chapman, Lt Carey and Lt Fernandez, he was their superior officer, as Chief Of Operations, Harry Kim, despite his rank was classed as a Senior Officer, therefore anyone higher in rank than Kim, who was not a Senior Officer, had to address him as "Sir"
As Timo indicated, Spock may have well been in Command of the Diplomatic Mission, however as Kirk was Commander of the Ent-A, the only thing Spock could do is order Kirk where to take the ship, what courtesies to extend and arrangements of security, specialist personnel, etc