The son of William Pepys, a banker, and his wife Hannah, daughter of Dr. Richard Russell of Brighton, was born in London on 26 May 1742. He was educated at Eton College and at Christ Church, Oxford, whence he graduated B.A. on 9 May 1764. He then studied medicine at Edinburgh, and afterwards graduated at Oxford, M.A. on 13 May 1767, M.B. on 30 April 1770, and M.D. on 14 June 1774.
Before his M.B. degree Pepys obtained a license to practice from the university of Oxford, took a house in London, and on 10 February 1769 was elected physician to the Middlesex Hospital, and held office for seven years. In the summer he used to practise at Brighton. He was elected a fellow of the Royal College of Physicians on 30 September 1775, was censor in 1777, 1782, 1786, and 1796, treasurer from 1788 to 1798, and president from 1804 to 1810. In 1777 he was appointed physician-extraordinary to the king, and in 1792 physician-in-ordinary. He was created a baronet on 22 January 1784. Pepys was elected a Fellow of the Royal Society in 1780.
Pepys attended George III in his mental disorder of 1788–9, and in that of 1804. He was examined on the subject of the king's health by a committee of the House of Commons on 7 January 1789. He then thought it likely that the king would recover in time, and stated that he had observed signs of improvement. He attended two days a week at Kew Palace, where the king was, from four in the afternoon till eleven the next morning, having a consultation often either with Sir George Baker or Dr. Richard Warren.
In 1794 Pepys was made physician-general to the army, and was president of an army medical board, on which it was his duty to nominate all the army physicians. When so many soldiers fell ill of fever at Walcheren, he was ordered to go there and report. As a consequence the board was abolished; but Pepys was granted a pension.
Pepys had a large practice, and after Edward Jenner's discovery he was an active supporter of the National Vaccine Institution. His house was in Park Street, Grosvenor Square, and he died there on 17 June 1830.
Pepys's only published work was the Latin preface to the London Pharmacopœia of 1809.
Pepys married, on 30 October 1772, Jane Elizabeth, Countess of Rothes, and had by her two sons and a daughter. He married again, on 29 June 1813, Deborah, daughter of Dr. Anthony Askew, who survived him.