Stephen J. Riordan Jr., 61, a retired Navy commander who later worked in the office of the chief of Navy materiel, died Monday at Suburban Hospital in Bethesda following a heart attack. He was stricken at his home in Rockville.

Cmdr. Riordan, who was born in Portland, Ore., graduated from the U.S. Naval Academy at Annapolis in 1942. His first assignment in World War II was aboard the cruiser Northampton. He was wounded when the ship was sunk off Guadalcanal. Later in the war, he served aboard aircraft carriers in the Pacific.

After the war, Cmdr. Riordan became a Navy pilot. He flew hurricane patrols until the Korean conflict, in which he served aboard ships and on land. He commanded a squadron at the Patuxent River Naval Air Test Center and then served in the Office of the Chief of Naval Operations. He retired in 1962.

For the next two years, Cmdr. Riordan worked for a defense contractor in Nashua, N.H. He then returned here and joined the National Aeronautics and Space Administration, working on the Apollo space program. About 1967, he transferred to the Navy Department and remained there until his retirement last year.

Cmdr. Riordan was a member of the Naval Academy Alumni Association and a volunteer at the Air and Space Museum in Washington.

Survivors include his wife, the former Margaret Mary Byrne, of Rockville; three sons, Navy Lt. Cmdr. Stephen J. III and Michael J., both of Rockville, and James J. of Chevy Chase, and three sisters in Portland, Ore.

The family suggests that expressions of sympathy be in the form of contributions to the Morningstar Boys Ranch, Spokane, Wash.