Shepard was born in Oswego, New York. On November 24, 1859 he received an appointment to the United States Naval Academy, from where graduated in 1861 at the start of the Civil War. He was assigned to the sloop-of-war Vincennes, and served on the West Gulf Blockading Squadron from 1861 to 1862.
On November 22, 1862 he was promoted to ensign and assigned to the sidewheel steamer Mississippi and continued to serve on the blockading squadron until 1863. He served on the ironclad gunboat Essex and was on board this ship during the siege of Port Hudson. Shepard received a letter of commendation from General Richard Arnold, who was General Nathaniel P. Banks' Chief of Artillery, after he had served on shore with a naval battery for several weeks.
Shepard served on the monitor Mahopac during the siege of Charleston, South Carolina, then on the steam sloop Wachusett during the capture of the Confederate privateer Florida on October 7, 1864. He was commissioned as a lieutenant on February 22, 1864.
After the capture of Florida Shepard served on the steamer Vanderbilt and the monitor Dictator before being assigned to the steamer Osceola, part of the North Atlantic Squadron. He then served on the apprentice-ship Saratoga from 1868 to 1869.
Shepard served on several other ships before being promoted to commander on 9 May 1878. From 1878 to 1881 he was at the Naval Academy, and immediately after from 1879 to 1881 commanded the Constitution, and then in 1882 Enterprise.