Cogswell returned to the United States for an overhaul in February 1945. Shepard was given three weeks' leave, in which time he and Louise decided to marry. The ceremony took place on March 3, 1945, in St. Stephen's Lutheran Church in Wilmington, Delaware. His father, Bart, served as his best man. The newlyweds had only a brief time together before Shepard rejoined Cogswell at the Long Beach Navy Yard on April 5, 1945. After the war, they had two children, both daughters: Laura, born in 1947, and Julie, born in 1951. Following the death of Louise's sister in 1956, they raised her five-year-old niece, Judith Williams—whom they renamed Alice to avoid confusion with Julie—as their own, although they never adopted her. They eventually had six grandchildren.
On Shepard's second cruise with Cogswell, he was appointed a gunnery officer, responsible for the 20 mm and 40 mm antiaircraft guns on the ship's bow. They engaged kamikazes in the Battle of Okinawa, where the ship served in the dangerous role of a radar picket. The job of the radar pickets was to warn the fleet of incoming kamikazes, but because they were often the first ships sighted by incoming Japanese aircraft, they were also the most likely ships to be attacked. Cogswell performed this duty from May 27, 1945, until June 26, when it rejoined Task Force 38. The ship also participated in the Allied naval bombardments of Japan, and was present in Tokyo Bay for the Surrender of Japan in September 1945. Shepard returned to the United States later that month.
In November 1945, Shepard arrived at Naval Air Station Corpus Christi in Texas, where he commenced basic flight training on January 7, 1946. He was an average student, and for a time faced being "bilged" (dropped) from flight training and reassigned to the surface navy. To make up for this, he took private lessons at a local civilian flying school—something the Navy frowned on—earning a civil pilot's license. His flying skills gradually improved, and by early 1947 his instructors rated him above average. He was sent to Naval Air Station Pensacola in Florida for advanced training. His final test was six perfect landings on the carrier USS Saipan. The following day, he received his naval aviator wings, which his father pinned on his chest.