The federal government could have saved $13.2 billion -- nearly one-half of last year's budget deficit if seven agencies had not gone on year-end spending sprees last fall, Rep. Herbert E. Harris (D-Va.) charged yesterday.

The huge Department of Housing and Urban Development alone spent nearly half of its 34 billion annual budget in August and September last year, the last two months of the 1979 fiscal year, according to a report given to Harris by the General Accounting Office.

Harris, along with 46 cosponsors, is pushing legislation that would limit agency spending in the last two months of a fiscal year to 20 percent on their annual budget. Using that formula, Harris estimated that agencies went out of their way to spend $13.2 billion.

Congressional critics contend that federal bureaucrats engage in frenzied spending near the end of the fiscal year, believing that their budgets will be cut the next time around if they do not spend every penny that has been appropriated.

Former Treasury Secretary W. Michael Blumenthal has characterized this "use it or lose it" mentality as "literally pushing money out the door with a wheelbarrow." A 21-year contracting officer at the Law Enforcement Assistance Administration told a congressional hearing that his agency spent money at the end of the year "like a car flying through an intersection seconds before the light turns red."

The Carter administration has repeatedly issued directives telling agencies to curb such spending -- the most recent on last Aug. 7 as the spending season was about to begin. James T. McIntyre, director of the Office of Management and Budget, asked agency heads "to make sure that we continue to use public funds wisely by avoiding unnecessary year-end buying."

Such warnings notwithstanding, the statistics supplied to Harris by the GAO this week showed year-end spending remains unchecked.

The GAO survey said HUD spent $16.107 billion, or 47.2 percent of its $34 billion budget, last August and September. If HUD had limited spending in those two months to 20 percent, that figure would have been cut by $9.293 billion.

A HUD spokesman said yesterday that arbitrary spending ceilings such as Harris' fail to take into account the way federal grants and contracts are awarded. Much of HUD's budget is paid out in grants to cities for community development programs.

"It takes time to set up the processes, and it is true it is near the end of the year before most of them are done," said Andy Gasparich, the HUD public affairs officer.

The other agencies that spent more than one-fifth of their budgets in the last two months of fiscal 1979 were: Environmental Protection Agency, $2.2 billion, or 41.7 percent of its appropriation; Commerce, $907 million, or 30.3 percent; Interior, $1.3 billion, or 23.1 percent; Health, Education and Welfare, $14.3 billion, or 22.9 percent; Transportation, $1.4 billion, or 22.8 percent, and the Postal Service, $3.2 billion, or 22.1 percent.

The annual spending sprees take different forms.

One mid-level bureaucrat sent a Sept. 8, 1978, memo to his boss, then U.S. commissioner of education Ernest Boyer, that said: "We have been able to identify $2,094,000, . . . which we are now able to declare surplus. These funds can be made available to you to allocate as you see fit."

Then, sounding like a television pitchman, he added, "we need to move quickly, as these funds lapse at midnight on Sept. 30.

Just in case Boyer didn't have any ready ideas on how to get rid of the money, the memo writer offered suggestions, including "remodeling of the commissioner and executive deputy commissioners's offices ($60,000)."

About the same time that memo was being circulated in Washington, the Denver office of HUD placed a rush order for $65,000 worth of office furniture.

When the wooden desks, over-stuffed couches, credenzas, chairs and filing cabinets were delivered, they were put in storage, where they remained for a year and a half, gathering dust and rental charges.

Lawrence Solomon, HUD's Denver regional inspector general for audit, said yesterday that the furniture was finally uncrated in January and sent to various HUD offices in the region to replace older furnishings.

"I don't yet know what happened to the older desks," said Solomon, who volunteered that "maybe those desks are now piled somewhere."

Solomon said HUD's administrative services division was so stung by his investigation that "they returned a lot of money, almost $30,000. They said they really needed it . . . but turned it back because they were scared.

While OMB annually issues pleas to stop year-end spending, some Carter administration officials have tried to play down the extent of the problem. W. Bowman Cutter of OMB said last November that while "some" abuse occurs, "I am persuaded that the extent of the problem has been exaggerated and in a way that could cause harm to rational government."

Harris concedes that his legislation might simply push the spending forward to the third quarter of the year, but he believes federal bureaucrats "are such poor budget managers that they won't be able to get that job done."

A report on an earlier version of the Harris bill by what was then the Civil Service Commission found that "legitimate cyclical reasons exist" for some increase in spending near the end of the fiscal year. But it went on to say that the "use or lose" syndrome "places government negotiators in a poor bargaining posture and results in contracts being let without adequate consideration."

Harris' legislation has been approved by the House Post Office and Civil Service Committee, and now is being considered by the Government Operations Committee.

In the meantime, Harris yesterday asked House Budget Committee Chairman Robert H. Giaimo (D-Conn.) to attach his 20 percent spending limit on the revised 1980 budget resolution that soon will be before his committee, and on the 1981 budget. He also asked McIntyre to impose such a limit on federal agencies this year.