Ogle was given command of the fourth-rate HMS Swallow and saw action against the pirate fleet of Bartholomew Roberts in the Battle of Cape Lopez in February 1722. The action was to prove a turning point in the war against the pirates and many consider the death of Roberts to mark the end of the Golden Age of Piracy.
In December 1741 Ogle was despatched with a fleet of some 30 ships to support Admiral Edward Vernon in his engagement with Spanish naval forces under Admiral Blas de Lezo off the coast of Colombia during the War of Jenkins' Ear. The attack on Fort San Lazaro was a disaster for the British forces and the Battle of Cartagena de Indias ultimately proved a decisive Spanish victory: 50 ships were lost, badly damaged or abandoned, and 18,000 soldiers and sailors died.