I guess that depends on whom you read. Two names, however, rise to the top: Admiral Thomas Cochrane and Admiral Edward Pellew; both individuals possessed the prerequisite skills that would have attracted Patrick O’Brian. The former was more flamboyant and controversial, the latter is considered the greatest frigate captain in the Royal Navy.
The partisans for Cochrane can point to this article – The real master and commander – that certainly presents a strong argument for Cochrane being the role model for Aubrey.
The case for Edward Pellew, who, if you remember, was featured in the early career of Hornblower, is convincingly laid out in this article – The Master and Commander revealed: The real Captain Jack Aubrey, at your service.
I am of the opinion that it is both, but be that as it may, here are some primary sources (along with a few secondary ones) that support their cases.
The trial of Charles Random de Berenger, Sir Thomas Cochrane, commonly called Lord Cochrane, the Hon. Andrew Cochrane Johnstone, Richard Gathorne Butt, Ralph Sandom…1814 [Trial proceedings on conspiracy of stock fraud. See below]
The case of Thomas Lord Cochrane, K. B. : containing the history of the hoax, the trial, the proceedings in the House of Commons, and the meetings of the electors of Westminster (1814) [This deals with Cochrane’s supposed role in the Great Stock Exchange Hoax of 1814. This work is his rebuttal.]
An address from Lord Cochrane to his constituents, the electors of Westminster. (1815) (From his prison cell]
A letter to Lord Ellenborough from Lord Cochrane. (1815) [Ellenborough is the judge who sentenced him.]
Narrative of services in the liberation of Chili, Peru, and Brazil, from Spanish and Portuguese domination (2 vols., 1859)
The life of Thomas, Lord Cochrane, tenth Earl of Dundonald; completing “The autobiography of a seaman.” ( 2 vols, 1869) [Written by his son, the eleventh Earl of Dundonald]
His speeches in Parliament. (use Cochrane or Dundonald, depending on the decade you are searching). You also have recourse to the Naval Chronicle and the London Gazette.
There does not appear to be a great deal of writing by Pellew available online. Here are his speeches in Parliament.
Some works of interest:
A narrative of the expedition to Algiers in the year 1816, under the command of the Right Hon. Admiral Lord Viscount Exmouth (1819)
The life of Admiral Viscount Exmouth (1835) [With a few examples of his writings in an appendix.]
Types of naval officers drawn from the history of the British Navy; with some account of the conditions of naval warfare at the beginning of the eighteenth century… (1901) [Chapter 7 on Pellew]
Edward Pellew (1934) [A goodly number of letters both to and from him.]