Robert D. Swezey, 72, a former government official and a broadcasting executive for nearly 40 years, died Tuesday at his Leesburg, Va., home after a heart attack.

He was a special assistant to secretary of labor Arthur Goldberg during the early 1960s, and was director of the Code Authority of the National Association of Broadcasters before serving as secretary-treasurer of the Corporation for Public Broadcasting from 1968 to 1970.

After leaving Public Broadcasting, he was president of MCI-Mid-Atlantic Communications for three years and served on the board of directors of MCI Communications. He also had worked for the International Executive Service Corporation.

Mr. Swezey came to Washington in 1934 as a legal adviser to the treasurer of the Home Owner's Loan Corporation, then worked as an attorney for the old Public Works Administration before going to New York City and joining NBC's legal staff in 1938. He was vice president and general manager of the Mutual Broadcasting System from 1944 to 1948 before returning to Washington.

He was a member of the City of New York, American, Federal Communications, and Boston bar associations. He belonged to the National Lawyers and University clubs in Washington.

Mr. Swezey was born in Somerville, Mass., and earned both bachelor's and law degrees at Harvard University. He practiced law in Boston and was a legal assistant in a New York City bank before entering government service.

Survivors include his wife, Helen B., of the home; a daughter, Sister Maria Swezey, R.S.C.J., of Korea; two sons, Robert D. Jr., of Washington, and Air Force Maj. William D.B., of the Phillippines; a sister, Helen Ehrensperger of Yankton, S.D., and seven grandchildren.