William Frederick Penniman Jr., 64, a former oil executive in the Middle East and a Foreign Service officer of the State Department, died Sunday in New York City after a heart attack.

He had been an official with Continental Overseas Oil Co. (Conoco) in the Middle East from 1962 to 1970, when he opened his own consulting firm, specializing in petroleum affairs, in Beirut.

He had maintained the Beirut offices until recently and continued to be a consultant for that area.

Born in Savannah, Ga., Mr. Penniman attended the University of Pennsylvania and the Wharton School of Finance and Commerce.

During the late 1930s, he joined the State Department and was assigned to Caracas, Venezuela. After World War II, when he served in the Marine Corps, he went to Santiago, Chile, as minerals and petroleum attache at the U.S. Embassy there.

Mr. Penniman was transferred to Jerusalem in 1950, and to Beirut a year later. He served with the petroleum policy staff at the State Department here in 1952.

He than left government service to join Conorada petroleum in Libya in 1953. After transferring to Conoco, he opened offices for that firm in Libya, Egypt, Paris, London and Beirut.

He is survived by his wife, Dorothy, of the home in Washington; four sons, Michael, of Philadelphia, Kingman, of Montpelier, Vt., Richard, of London, England, and William, and two grandchildren.