Standing next to his Treasury Department office, Robert Dexter reached inside a cabinet full of illegal explosives, took out a can of black powder and poured some into his palm. A few grains sifted through his fingers and onto the floor as the federal government's leading authority on fireworks pointed out cherry bombs and military explosives.

"You see these?" he asked, picking up a plastic bag containing multicolored pellets. "They look like Trix cereal. If a kid puts one in his mouth and bites down, it'll blow his jaw off."

Dexter doesn't mince words. His 35 years in the explosives business -- 25 in the military and the last 10 in the federal bureaucracy -- have taught him a healthy respect for fireworks.

Now, as chief of the explosives technology branch of the Treasury Department's Bureau of Alcohol, Tobacco and Firearms, he oversees the $100 million-a-year fireworks industry and tries to cut down on the thousands of injuries caused by fireworks and firecrackers each year.

The seven people in the bureau's explosives branch devote most of their time to bombs, but they also regulate the manufacture and sale of powerful firecrackers and fireworks.

Large firecrackers, such as cherry bombs, have been banned nationwide since 1966, and each year the bureau raids at least a half-dozen factories making illegal fireworks, Dexter said. Last week the bureau closed a factory in California and seized 57,000 illegal M80 (cherry bomb-like) firecrackers.

"I personally have destroyed 5 million illegal fireworks," said Dexter, who recalled that as a boy in Boston he set off M80s in tin cans. After a raid, the agency buries the firecrackers and douses them with water and detergent to defuse them.

The bureau also is responsible for regulating large firework displays, granting permits for about 2,000 shows each year to sponsoring companies, according to Patricia A. Murphy, the bureau's public information officer.

Laser light shows sometimes incorporated in fireworks displays belong to yet another regulatory domain: the Food and Drug Administration. The FDA regulates all consumer and medical products that emit radiation, from microwave ovens to video display terminals to lasers.

The relatively powerful lasers usually used in light shows require a variance from FDA rules, FDA press officer William Rados said. Since the rules were established in May, 1980, more than 60 requests for variances have been received, he said, six for Independence Day this year.

Smaller Fourth of July fireworks are the responsibility of the Consumer Product Safety Commission and the U.S. Customs Service, if the fireworks are imported, as an estimated two-thirds are.

About 50 CPSC staffers across the country devote some of their time to monitoring the manufacture of legal fireworks, such as sparklers and smoke devices, particularly how they are labeled and packaged.

The CPSC also works with Customs agents to stem the flow of illegal firecrackers from abroad, especially China, Heidi H. Bowers, a commission press aide, said. Laws in Canada and Western Europe governing fireworks are similar to those in the United States, while in Mexico and South America there often are no regulations, according to Jack Leonard, past president of the Pyrotechnic Guild International.

Fireworks are permitted in the Soviet Union and China, he said, but are frowned upon as contrary to the revolutionary worker spirit.

Aside from the national ban on cherry bombs, rules on fireworks vary greatly among the states and cities. Nevada and Hawaii have no regulations, while 15 states prohibit fireworks, even sparklers. Virginia and the District of Columbia permit small fireworks, while Maryland prohibits sale and possession of all fireworks except sparklers. Local jurisdictions refine the laws even further; Montgomery County, for example, bans all fireworks, even sparklers.

Seven more states permit fireworks now than did a decade ago, and the safety commission's estimate of the number of injuries also has risen. Spokesmen for the fireworks industry insist there is no connection.

Leonard, a fireworks hobbyist in White Marsh, Md., said that in states where fireworks are banned people tend to use more powerful firecrackers that they buy illegally, resulting in more injuries. Leonard cited a study showing that Massachusetts, where fireworks are prohibited, had more injuries than Virginia, where minor fireworks are permitted.

"Nothing is perfectly safe," Leonard said. "A bicycle isn't perfectly safe."

The CPSC reported that in 1980 fireworks caused 9,400 injuries that were treated in hospital emergency rooms and 10 deaths, Bowers said.

Two-thirds of the injuries resulted from misuse, and most of the remaining involved illegal fireworks, she said. Most injuries involve children. Blast We Must, But Let's Do It Safely and Sanely

The Consumer Product Safety Commission offers this advice on how to use fireworks safely:

Keep children away from them.

Buy only fireworks with labels, as others may be illegal.

Don't set off fireworks indoors or close to anything that might catch fire.

Keep a bucket of water handy in case a fire starts.

If a device fails to go off, leave it alone for at least 10 minutes and then douse it with water.