(covers information from several alternate timelines)
The position of acting captain was bestowed upon an officer or another individual aboard a starship when the ship's regular commanding officer was unable to command for an extended period of time. The first person eligible was generally the first officer, with the line continuing down the ranks until someone was both physically and psychologically able to command.
In 2151, when Captain Jonathan Archer lost consciousness after a fight between the Suliban Cabal and Sarin's group of renegade Suliban, T'Pol became the acting captain of Enterprise. (ENT: "Broken Bow")
Later that year, Paul Mayweather, temporary captain of the ECS Horizon, joked with his brother Travis Mayweather, citing that "An ensign ought to salute before addressing a captain." Ensign Mayweather laughed it off, reminding him that he was only that "acting captain" and not to "let it go to your head." (ENT: "Horizon")
In 2154, when Captain Archer became obsessed with protecting a Xindi-Insectoid hatchery due to a chemical from the hatchery's eggs, Trip led a mutiny in order to bring Captain Archer back to Enterprise so that they would be able to continue their mission to stop the Xindi from destroying Earth. During the time that Archer was recovering, T'Pol was the acting captain of the Enterprise. (ENT: "Hatchery")
Later on, after the Discovery jumped into a parallel universe, Commander Saru again became acting captain of the ship due to Captain Lorca leaving to act on his plan to be brought before Philippa Georgiou. (DIS: "Despite Yourself") The crew was ultimately faced with the revelation that the Lorca they knew had been from the mirror universe all along, leaving Saru as acting captain indefinitely. (DIS: "What's Past Is Prologue")
In 2266, with Captain James T. Kirk being detained by the staff on Tantalus V, Spock was the acting captain of the Enterprise and referred to himself as such in the ship's log. (TOS: "Dagger of the Mind")
While under the influence of the polywater intoxication, Wesley Crusher deemed himself "acting captain" of the USS Enterprise-D in 2364 after commandeering the ship from engineering. (TNG: "The Naked Now")
On several occasions from 2372 until 2375, Lieutenant Commanders Worf and Jadzia Dax were made acting captain of the USS Defiant for missions in the Gamma Quadrant and during the Dominion War. Captain Benjamin Sisko was the commander of Deep Space 9, which during the war was the headquarters for the Federation Alliance, and would often demand his close attention. As such he would entrust to his most senior Starfleet officers command of the ship and its crew. (DS9: "Rejoined", "Paradise Lost", "Call to Arms", "Behind the Lines")
Aboard the Silver Blood USS Voyager, its copy of Ensign Harry Kim assumed command of the starship as the highest ranking surviving officer, after his own senior officers had dissolved. (VOY: "Course: Oblivion")
In the alternate reality 2233, Lieutenant Commander George Kirk, first officer of the USS Kelvin became acting captain of that vessel after Captain Richard Robau was forced to leave the ship and was subsequently killed. Captain Christopher Pike, who later wrote a dissertion on the incident noted that Kirk was captain of a starship for a mere twelve minutes but saved the lives of the eight hundred crewmembers aboard the ship.
In 2258, in the same reality, Captain Pike of the USS Enterprise appointed Commander Spock acting captain and George Kirk's son, Lieutenant Kirk as first officer when Pike left the ship to confront Nero. Subsequently, Kirk proved that Spock was unable to perform his duties and then Kirk himself was made acting captain. After everything was over, Kirk was promoted to the rank of captain and given regular command of the ship. (Star Trek)
Later, in 2259, Kirk placed Hikaru Sulu in charge when he and other members of his crew flew a K'normian trading ship to Qo'noS to apprehend John Harrison, a move which Leonard McCoy questioned, saying, "You just sat that man down at a high-stakes poker game with no cards and told him to bluff." Kirk rebuffed his concerns.
As acting captain, Sulu ordered the refueling and preparation of the K'normian ship for Kirk and his team. He also delivered an ultimatum to Harrison that impressed McCoy and caused the doctor to revise his earlier opinion.
When Kirk was aboard the USS Vengeance, and the Enterprise was falling towards Earth, Spock, in the role of acting captain, ordered the entire crew to evacuate the ship while he remained behind to ensure their safety until they did. Sulu and the rest of the bridge crew declined, strapping themselves in. (Star Trek Into Darkness)