An estranged couple, quarreling bitterly over custody arrangements for their two infant sons, transformed an Agriculture Department office into the scene of a tense 3 1/2-hour drama yesterday, with the husband holding a razor blade beside his wife's throat.

According to accounts by metropolitan police officials, the husband, an Internal Revenue Service mail and records supervisor, held his estranged wife, an Agriculture Department researcher, as a hostage in the small office overlooking C Street SW until their children were flown here by helicopter from Baltimore.

The husband, identified as Eli N. Williams, 33, eventually freed his wife, Annette M., 37, and surrendered to police after their children were brought to the street outside the Agriculture Department office. Williams viewed his sons briefly from the fourth-floor window, police said. Then he gave himself up.

The couple's children - Jason, 21 months old, and Eli, 7 months - arrived her in a Maryland State Police helicopter that landed on the Washington Monument grounds. According to police, the children had been staying in West Baltimore with relatives of their mother. They were later turned over to a woman identified by police as Shirley Williams, a cousin of their father.

Metropolitan police later charged the father with armed kidnaping in the incident at the Agriculture Department office. According to police, he was being held last night pending a court arraignment today.

His wife was only slightly injured during the ordeal. A George Washington University Hospital spokeswoman said she had suffered small cuts on both hands and a bruise on the top of her head. According to police, the cuts were apparently inflicted at the start of yesterday's incident.

Police described the couple as informally separated, with the wife living in Washington and the husband near Seat Pleasant, Md. The quarrel over custody arrangements for their children appeared unresolved. Police said Williams was seeking legal help in the custody dispute, while his wife had demanded last night that the children be returned to her.

Police said, however, that the children would remain overnight with the father's relative. The case will go today to the family division of Superior Court for resolution.

Yesterday's drama began, according to police, when Williams walked into an Agriculture office at 9:30 a.m. He grabbed his wife, putting his right arm around her throat, police said, and with his left hand, held a single-edged razor blade against her throat. He led her to a small red chair near a window.

"He was very violent in the beginning and very irrational and very touchy." Police Chief Maurice J. Cullinane said after the incident. "He was very hostile at first but he got better and better."

Initially, police said, Williams had demanded that he be given custody of the children, but eventually he accepted a compromise under which the two infants were turned over to his relatives. Cullinane said Williams also demanded that television and other news reporters be kept at a distance from his children in an attempt to prevent the infants from being photographed.

Two police officials - Capt. George Richards and Lt. Isaac Fulwood - were permitted inside the Agriculture office to negotiate with Williams. Two of his cousins also were allowed into the room.

As negotiations continued, police cordoned off a wing of the Agriculture building and blocked off a section of C Street SW, west of 12th Street. The incident drew a crowd of news reporters and curious government employees. Neither Williams nor his estranged wife spoke with reporters.

Williams, according to government officials, had worked for the IRS since November, 1975, and was supervisor of the mail and records section of the IRS exempt plans division. His pay grade was GS-7. He had previously worked in the Agriculture Department's supply room.

His wife, government officials said, has worked for Agriculture since 1970 and is a researcher in the department's statistical reporting section, with a civil service rating of GS-14. She was born in Baltimore, where she attended high school. She later attended Howard University from 1956 to 1958, officials said.