Many mentions of O'brian; some other Royal Navy series that I also liked:
Alan Lewrie series by Dewey Lambdin; a much spicier version of a royal navy officer. Fighting, sailing, sex, run-ins with historical characters, sex, incest, sex. Oh, and sex.
The Sea Officer William Bentley series, by Jan Needle, including A Fine Boy for Killing, and the Sea Nymph. Bentley starts off as a callow midshipman aboard his pyscho uncle's ship, and grows into an admirable fellow.
The Kidd series by Julian Stockwin, including Artemis, Seaflower, Mutiny and Quarterdeck. Different, in that the hero starts off as a common sailor, not an officer.
Anything by James Nelson, including his Revolution at Sea saga and his Bretheren of the Coast (pirates) series. He also has a Civil War series.
Don't forget Hornblower. Some people put down the series as paling in comparison to O'brian, but I think he's an interesting character and his sailing and battle scenes are second to none.
Modern sailing novels:
Tony Gibbs wrote a series of books about a charter yacht in the Caribbean: Running Fix and Landfall were two of them. Danger, murder, intrigue, politics, drinking, romance. Lots of fun.
Sam Llewlellyn: often called the "Dick Francis" of sailing, Sam wrote a number of fine murder mysteries centered on various yachts and sailboats. Also, check out his "sequel" to the Riddle of the Sands.
Flirting with Mermaids by John Kretschmer; tales from a delivery skipper
All this and Sailing Too; autobiography of Olin Stephens
Wanderer; autobiography of Sterling Hayden. The movie star was a bona fide sailor/adventurer before he turned to Hollywood. Fascinating.
A Fair Wind and Plenty of It; a tale of a circumnavigation aboard a replica tall ship.