W. Stafford Shaw, 71, a Washington banker for 40 years who retired in 1971 as a vice president of the old Union Trust Company, died Friday at his home in Arlington. He had a heart ailment.

Mr. Shaw began his banking career in 1931 with the old Munsey Trust Company, where he was an assistant treasurer, assistant real estate officer, and finally a vice president, before that bank merged with Union Trust in the late 1950s.

After the merger, he joined Union Trust as a vice president and manager of the Munsey Branch, posts he held until retiring. Union Trust later merged with the First National Bank of Washington.

In addition to his banking career, Mr. Shaw was treasurer of the National Slag Association, a trade organization with headquarters in Alexandria, from 1934 to 1979.

He was a member of the Washington Metropolitan Board of Trade and the American Banking Institute.

Mr. Shaw was a native of Washington and earned bachelor's and master's degrees at Benjamin Franklin University and attended Rutgers University's graduate of St. Thomas.

He was a member of St. Thomas More Catholic Church in Arlington. He was a member of the John Carroll Society and the Knights of Columbus.

Survivors include his wife, M. Aleese Shaw of Arlington; two daughters, Mary Aleese Schreiber of Little Rock, Ark., and Sister Ann Shaw, C.S.C., of Columbus, Ohio; two sons, James S., of Springfield, and William J., of Falls Church; Two sisters, Genevieve T. Muldoon of Rockville, and Mary T. Spitler of Washington, and nine grandchildren.

The family suggests that expressions of sympathy be in the form of contributions to the Hospice of Northern Virginia.