As I have written before WNMHGB is annoying vague about who holds the position of first officer and/or second in command.
Mitchell acts like he has responsibilities beyond helm officer here:
MITCHELL: Department heads, sir. You wanted everybody on the Bridge before we left the galaxy. Jones.
SMITH: The name's Smith, sir.
SULU: Astro sciences standing by, Captain.
SCOTT: Engineering division ready, as always.
PIPER: Life sciences ready, sir. This is Doctor Dehner, who joined the ship at the Aldebaran colony.
DEHNER: Psychiatry, Captain. My assignment is to study crew reaction in emergency conditions.
When they approach the barrier Spock gives orders to Kelso, meaning that he not only has a senior rank but is above Kelso in Kelso's chain of command:
SPOCK: Sensor beam on.
KELSO: Sensor beam on, sir.
SPOCK: Deflectors full intensity.
KELSO: Deflectors full intensity.
After Mitchell is disabled Kirk takes the helm and then is replaced at the helm by Spock. Kirk orders Spock:
Take damage reports.
SPOCK: Damage control reports, all stations!
SPOCK: Main engines are out, sir. We're on emergency power cells. Casualties, nine dead.
If Spock was the first officer and second in command he might have asked for damage control reports without a command from Kirk. Kirk could have ordered someone who wasn't the first officer to take damage reports.
It is possible that Mitchell was the first officer but was unconscious and then off duty in sickbay and Spock had to assumed many of Mitchell's duties.
DEHNER: I don't think so. I understand you least of all. Gary told me that you've been friends since he joined the service, that you asked for him aboard your first command.
KIRK: It is my duty, whether pleasant or unpleasant, to listen to the reports, observations, even speculations, on any subject that might affect the safety of this vessel, and it's my science officer's duty to see I'm provided with that. Go ahead, Mister Spock.
So Spock is stated to be Kirk's science officer, making his relationship with Sulu the head of the Astro sciences Department uncertain. And it is left uncertain whether Spock was already also Kirk's second in command and first officer.
In "The Enemy Within" , the 4th TOS episode produced, the 5th in airdate order (6 October), the 6th in stardate order (1672.1):
Captain's Log, stardate 1673.1. Entry made by Second Officer Spock. Captain Kirk retains command of this vessel, but his force of will rapidly fading. Condition of landing party critical. Transporter unit still under repair.
In "Dagger of the Mind" the 11th TOS episode produced, the 9th in airdate order (3 November 1966), the 13th in stardate order (2715.1):
SPOCK: Enterprise log. First officer Spock, acting captain. I must now use an ancient Vulcan technique to probe into Van Gelder's tortured mind.
In the trial in "Courtmartial", the 15th episode produced, the 20th episode in airdate order (2 February 1967), and the 16th episode in stardate order (2947.3):
COMPUTER: Spock, serial number S179-276SP. Service rank, Lieutenant Commander. Position, First officer, science officer. Current assignment, USS Enterprise. Commendations, Vulcanian Scientific Legion of Honour. Awards of valour. Twice decorated by Starfleet command.
SHAW: Mister Spock, as a First officer, you know a great deal about computers, don't you?
So at that time Spock has the positions of first officer and science officer and the rank of lieutenant commander.
In "The Menagerie", the 16th TOS episode produced, the 11th in airdate order (17 November 1966), the 17th in stardate order (3012.4), Spock is referred to as first officer and as lieutenant commander:
MENDEZ: The fact remains that your first officer's former captain is hospitalised, horribly injured, at this base, and that same first officer seems to be the only one who heard that message.
SPOCK: Maintain radio silence, Lieutenant. This is First Officer Spock. Per Starfleet orders this date, I have been placed in temporary command of the Enterprise. While our destination is secret, our mission is relatively simple. Starbase Command has assigned Captain Kirk medical rest leave until our return. His instructions are that you will obey my orders as you would his. First Officer out.
SPOCK: This is the First Officer speaking. Security, send an armed team to the Bridge. Transporter Room, stand by to beam Captain Kirk aboard. Effective until then, Lieutenant Hansen is in operational command.
HANSEN: Sir?
SPOCK: First Officer out. Doctor, as senior officer present, I present myself to you for arrest.
Captain's log, stardate 3012.4. Despite our best efforts to disengage computers, the Enterprise is still locked on a heading for the mysterious planet Talos Four. Meanwhile, as required by Starfleet General Orders, a preliminary hearing on Lieutenant Commander Spock is being convened. And in all the years of my service, this is the most painful moment I've ever faced.
In "Tomorrow is Yesterday":
CHRISTOPHER: I never have believed in little green men.
SPOCK: Neither have I.
KIRK: Captain Christopher, this is my First Officer, Lieutenant Commander Spock.
In "Space seed" When it seems the bridge crew are all dying Kirk logs:
Stardate 3142.8. They have my ship, discarding their own worthless vessel. Only moments of air left on the Bridge now. Commendations recommended for Lieutenant Uhura, Technicians First Class Thule and Harrison, Lieutenant Spinelli and, of course, Mister Spock. I take full responsibility. I take full (He passes out)
And we may wish that Kirk had though to give Spock's precise rank at the time. In "The Immunity Syndrome":
KIRK: (also making a log entry) We have arrived at the chromosome body in the nucleus of the organism. If we should fail in our attempt to destroy it, or be unable to free ourselves, I wish to record my recommendations for the following personnel, that they receive special citation. Lieutenant Commander Leonard McCoy, Lieutenant Commander Montgomery Scott, officers Chekov, Kyle, Uhura, and my highest commendation for Commander Spock, Science Officer, who gave his life in the performance of his duty.
Here Kirk describes McCoy and Scott as lieutenant commanders and Spock as commander, thus strongly indicating that Spock has been promoted to commander by then.
And I think that is most of the important information that can be used to deduce Spock's rank and positions in TOS, except that as far as I know Spock always wore the two solid stripes of a full commander while other characters said to be lieutenant commanders wore one solid stripe and on dashed stripe.