"O-5" was laid down on 8 December 1916 by the Fore River Shipbuilding Company of Quincy, Massachusetts. She was launched on 11 November 1917, and commissioned on 8 June 1918 with Lieutenant commander George A. Trever in command. During the final months of World War I, "O-5" operated along the Atlantic coast and patrolled from Cape Cod to Key West, Florida. On October 6, 1918 "O-5" was at the Brooklyn Navy Yard when Lieutenant (Junior Grade) William J. Sharkey noticed that the submarine's batteries were giving off toxic gas. Sharkey informed his commanding officer and the two went forward in the submarine to investigate. The batteries then exploded killing LTJG Sharkey and fatally injuring LCDR Trevor. LTJG Sharkey was posthumously awarded the Navy Cross. "O-5" departed Newport, Rhode Island on 3 November 1918 with a 20-submarine contingent bound for European waters; however, hostilities had ceased before the vessels reached the Azores.