Robert H. Taylor, 54, a retired Secret Service agent who helped protect five presidents and who was the head of the White House detail under Presidents Johnson and Nixon, died of cancer Thursday at Georgetown University Hospital.

Mr. Taylor joined the Secret Service in 1950. He retired in 1973 due to a knee injury he suffered in 1966 when an armored car ran over his foot in Australia. At the time, he was accompanying President Johnson on a trip which was distinguished by the tumultuous welcome the president received and by Johnson's determination to get as close to the crowds as possible.

In the course of his career, Mr. Taylor received two medals. The first was for his work in 1958 when he accompanied Nixon, then the vice president, to South America. In Caracas, Venezuela, Nixon was greeted by a hostile and unruly crowd that crowded around the open car in which he and his wife were riding. The second was for the logistical arrangements he made for Vice President Hubert H. Humphrey's trip to Vietnam in the late 1960s.

Mr. Taylor was head of the Secret Service's prestigious White House detail from 1967 until he retired in 1973.

A native of Iola, Kan., Mr. Taylor grew up there and in Dodge City, Kan. He served in the Navy and later graduated from Wichita University in Wichita, Kan. He also worked for two years on the Wichita police force while he was a student.

After retiring from the Secret Service, Mr. Taylor spent a year setting up a security system for the New York Racing and Wagering Board. From 1974 to 1978, he was in charge of security arrangements for the entire Rockefeller family. In 1979, he returned to the Washington area and established his own security consulting firm. He lived in Falls Church.

Survivors include his wife, Loretta, of Falls Church, a daughter, Karen Lk,. McLaughlin, of Denver, and a sister, Evelyn Myer, and his parents, Mr. and Mrs. clyde H. Taylor, all of Wichita. A son, Kenneth, was killed in an accident in 1971.

The family suggests that expressions of sympathy be in the form of contributions to the Robert H. Taylor Scholarship Memorial Fund, c/o U.S. Secret Service, Office of Inspection, Washington, D.C. 20223.