WASHINGTON (AP) _ Union Carbide Corp. agreed Friday to pay a record $408,500 fine for contested job health and safety violations, settling a landmark case involving two West Virginia plants including one where it was accused of exposing unprotected workers to a deadly gas.

The nation's fourth largest chemical company denied violating the law. But it said resolving the case and agreeing to pay a reduced fine was cheaper than continuing to fight charges of more than 500 violations filed against it last year by the Occupational Safety and Health Administration.

OSHA originally fined the company $1,377,300 for 221 violations, including 127 described as ''willful'' or deliberate disregard of the law, at its chemical plant in Institute, W.Va.

Later, another $90,000 in fines were levied for 335 alleged ''willful'' violations at another Carbide plant less than 20 miles away at South Charleston, W.Va.

The settlement ends what was a landmark case for OSHA in enforcing the nation's job safety laws.

The Institute fines levied in April 1986 were the first time during the Reagan administration that the agency sought the maximum $10,000 penalty for each individual ''willful'' violation of the law.

In the interim, OSHA has sought more than $8 million in fines against 15 other major corporations, including proposing one of nearly $2.6 million earlier this week against IBP Inc., the nation's largest meatpacker. Most, like IBP and Union Carbide, have contested the citations and fines.

Previously, the adminsitration's OSHA enforcement policy to was to lump together similar violations by an employer and treat them as one citation with one fine of $10,000 or less.

''There should no employer in the country today who is unaware of how this agency feels,'' Terry Mikelson, an OSHA spokesman, said Friday.

Just three weeks ago, OSHA collected its largest penalty ever, nearly $1.6 million from the Chrysler Corp. for exposing workers to hazardous levels of lead and arsenic at auto assembly plants.

Chrysler, however, did not contest the fine. Mikelson said the Carbide settlement is the largest ever collected by the agency from a company that had challenged its citations.

The settlement agreement with Carbide includes the ''standard non-admission clause in which the company accepts responsibility but does not admit guilt,'' Mikelson said

But he said the ''willful'' characterization by OSHA of the violations also stands as part of the agreement, including one that accused managers at the Institute plant of requiring workers to ''sniff'' for the presence of deadly phosgene gas when alarms indicated a leak of it.

''They used to use canaries for that,'' Labor Secretary William E. Brock said when OSHA issued the citations 16 months ago, warning that other companies which ''blatantly violate safeguards'' could expect the same type of penalties.

Phosgene was a major ingredient of mustard gas blamed for a million deaths when used as a weapon during World War I.

Union Carbide President Robert Kennedy had called Brock's remarks ''an outrageous misrepresentation of the truth'' and had vowed that his company would vigorously contest the fines.

But company officials said Friday that continuing the fight before Labor Department law judges and possibly later in court would cost several times the amount of the reduced settlement penalties.

''In settling this case, we specifically denied any violation of the law and continue to believe we have strong legal defenses,'' said Harvey Colbert, a Carbide spokesman. ''We particularly dispute OSHA's contention that any of our employees were required to be exposed to phosgene.''

''However, we must look at the economic realities,'' Colbert said. ''The dollar figure involved in settling this case constitutes only a fraction of what it would have cost to litigate the case fully.''

The alleged violations at the two plants ranged from failing to keep proper records of employee injuries and illnesses to inadequate safety management systems for recognizing and correcting hazards.

The fines were proposed following wall-to-wall OSHA inspections of the plants after a chemical leak at the Institute facility in August 1985 hospitalized six workers and sent 129 area residents to emergency rooms.