Hepburn joined the 3rd Foot Guards of the British Army as an ensign on 17December 1794 and was promoted to lieutenant and captain on 28May 1798. He saw service in the Irish Rebellion of 1798 and the following year accompanied the expedition to the Helder in Holland. Promoted to captain and lieutenant-colonel on 23July 1807, at the 1811 Battle of Barrosa he was seriously wounded in the leg by a musket ball but refused amputation knowing that it would cut short his military career. Nevertheless, he was forced to return home owing to the injury and did not arrive back in the Iberian Peninsula until the autumn of 1812 when he took charge of a small corps of sharpshooters. He saw further action at the battles of Vittoria, Nivelle and the Nive during the Peninsular War, for which he received the Army Gold Medal and one clasp.