It's becoming part of the annual budget ritual for the National Bureau of Standards, the Commerce Department's sprawling research center in Gaithersburg.

Every year the Reagan administration tries to kill two of the bureau's best-known programs -- one on how fires spread, the other on the structural qualities of building materials and architectural designs.

And every year Congress rebuffs the attempt.

This year, once again, both the House and Senate appear to be coming to the rescue. Committees in both houses have restored the programs in marking up the bureau's fiscal 1986 authorization. It remains to be seen, of course, whether the funds will survive, as they always have, once the budget-writing is completed.

"It's getting to be something of a morale problem for the people in these programs," said Mat Heyman, the bureau's chief of media liaison. "They're never sure they're going to be in business next year."

Although NBS Director Ernest Ambler gamely told congressional committees that it would be "appropriate" for the two research efforts to be picked up by private industry and state governments, he was followed by a parade of private-sector witnesses who said that was unlikely to happen.

Spokesmen for the construction and insurance industries praised both programs as essential to making homes, office buildings and other structures safer from fire and making buildings, bridges and other large structures safer from deterioration and collapse.

The Center for Fire Research, currently budgeted at $5.1 million, has become famous for such projects as constructing a bedroom inside a special laboratory building, furnishing it completely and dropping a lighted cigarette on the bed to see exactly how fires start and spread. Heat-shielded cameras, thermometers and other devices record the fire's progress second by second.

Experiments such as these have led to better methods of fireproofing, improved architectural designs and even recommendations on how best to escape a burning bedroom. But the information is also being used to determine the fire-vulnerability of buildings that exist only as architectural drawings.

The United States, bureau scientists like to point out, has one of the worst fire-loss records in the industrialized world and needs to know more about how to prevent or retard fires.

The Center for Building Technology, which will cost $3.1 million this year, tries to respond to similar needs, made all the more obvious with disasters such as the collapse of a suspended walkway in the Hyatt Regency Hotel in Kansas City, Mo., that killed 114 and injured 185 in 1981. Scientists from the center investigated that accident, as they do most other unexpected collapses of buildings and bridges.

The center is embarking on a major search for ways of protecting structures from earthquake damage. As part of its work, it also builds such things as bridge support pillars and tries to shake them apart on its own artificial earthquake machine.

Overall, NBS' budget request has fared well in Congress, despite the Reagan administration's effort to cut it from the current $124 million to $120 million in fiscal 1986. The Senate Commerce Committee so far has boosted it to $129.7 million. The House committee went even higher, to $139.9 million.

Congress traditionally has smiled on the bureau because of its reputation as a politically neutral developer of the nation's standards for almost everything -- ordinary weights and measures, computer technologies and biomedical laboratory testing equipment, among other things.

NBS is among the least politicized of federal agencies. Perhaps for this reason its management is among the most stable. Ambler, its current director, is a physicist who went to work for the agency in 1953, was appointed director by President Gerald R. Ford in 1975 and reappointed by both Presidents Jimmy Carter and Reagan. LABS FOR HIRE . . .

Although the bureau has long prided itself on conducting open research with full public access, Ambler recently implemented a policy that will allow private industry to hire the agency's facilities, though not its staff, for proprietary research. Many NBS labs and special facilities are either unique or superior to those in industry. As long as the private company can show it has no alternative and if the use will not interfere with NBS research, the company can bring its own scientists in to work.