Washington officials were "sucking in their breath," as one put it yesterday, after Egyptian President Anwar Sadat said in a television interview that the United States has been secretly buying old Soviet-made arms from him and slipping them to rebels fighting Soviet forces in Afghanistan.

The U.S. effort, led by the Central Intelligence Agency, to help supply the Afghan resistance has always been labeled top secret, although several news stories, based on accounts supplied by unidentified sources, have reported on the operation.

There has never been official confirmation of the operation, and the fact that it now comes from a major western head of government has left many senior government officials here unhappy and puzzled as to why Sadat went public.

Sadat made his comments in Cairo in an NBC News television interview broadcast here Tuesday night. Soon after the Soviets invaded Afghanistan in December, 1979, "the United States sent me airplanes and told me 'Please open your stores for us so that we can give the Afghanis the armaments they need to fight,' and I gave the armaments," Sadat said.

Sadat said the arms were of Soviet manufacture supplied to Egypt prior to 1972 before Sadat threw the Soviets out of Egypt.

On Feb. 15, 1980, The Washington Post reported that the United States was covertly slipping weapons, mostly Soviet-made small arms, to the rebels across the Pakistani border. The Soviet presence helped to disguise the weapons' origin, and the arms were available in countries such as Egypt.

In the interview, Sadat said he continues to supply arms and will do so "until the Afghanis get . . . the Soviets out of their country."

In Washington yesterday, sources who declined to be identified in any way said there is only speculation as to why Sadat gave official recognition to the operation.

Some thought it simply a result of getting too expansive in an interview. Others saw it as perhaps Sadat's way of demonstrating that Egypt, too, has a strategic relationship with the United States, just as the Reagan administration recently announced the United States has with Israel.

In another view, Sadat, highly praised throughout much of the West as a leading world statesman and man of courage, faces domestic political problems and may simply have felt frustrated and wanted to show the extent of his involvement in matters requiring decisiveness.

Some sources said they assumed the Pakistanis would be the most annoyed at Sadat's remarks. Pakistan has borne the brunt of many problems in the wake of the Soviet invasion, including millions of Afghan refugees fleeing into Pakistan and constant pressure from Moscow not to allow its territory to serve as a conduit for rebel arms.

Officials at the State Department and CIA had no comment on Sadat's remarks.