The Supreme Court agreed for the first time yesterday to decide whether mandatory drug testing for federal employees violates the Fourth Amendment protection against unreasonable search and seizure.

Confronted with conflicting appeals court rulings on the issue, the justices agreed to hear an appeal by Customs Service employees, who challenged a program that subjected anyone seeking a job or promotion in certain "key" positions to mandatory testing.

The action, which came on the opening day here of the White House Conference for a Drug Free America, puts the court for the first time in the center of a growing national debate on use of drug testing to deter and expose users.

In recent years, the justices have rejected appeals of decisions upholding random testing for jockeys and bus drivers. A ruling in this case, not expected to be heard before October, would not directly affect drug testing by private employers.

The Reagan administration announced plans in 1986 to institute random drug testing immediately for federal workers in sensitive positions.

Justice Department spokesman Terry Eastland said yesterday that the court's action would not affect the administration's timetable. "Our intention is to move ahead with our drug-testing program," he said.

The program, stalled while agencies formulate specific plans to address congressional concerns, may be implemented as early as May, according to administration officials. Some federal employees, including military personnel and Transportation Department employees, are subject to urine testing to detect drug use.

The case, National Treasury Employees Union v. Von Raab, began after the service announced plans to require urinalysis tests for employees who are directly involved in drug-interdiction programs, carry weapons or have access to classified information.

The union, which represents the Customs Service's 9,000 employees, sued, arguing that such testing is not based on "reasonable suspicion" of drug use in an individual case and therefore violates the Fourth Amendment.

The union also contends that urine tests will do little to find or deter users, because anyone who is accepted for a job or promotion and uses drugs simply can abstain briefly.

A federal judge ruled the program invalid, but a divided three-judge panel of the 5th U.S. Circuit Court of Appeals in New Orleans upheld the testing.

The appeals court said that the requirement that workers provide urine samples is a search subject to constitutional considerations but that the testing is not unreasonable, given the "strong governmental interest in employing individuals for key positions in drug enforcement who themselves are not drug users."

Last June, the high court refused the union's request to have the testing program delayed pending review.

The administration, which had opposed granting the union's appeal, withdrew its objections last week after a contradictory ruling by a divided federal appeals court panel in California Feb. 11.

That ruling struck down as unconstitutional a mandatory drug and alcohol testing requirement of the Transportation Department for railroad workers involved in accidents. The court said the testing, which covers 200,000 railroad workers, is invalid because it does not require "particularized suspicion."

Solicitor General Charles Fried, in a letter to the court last week, said the government will file an appeal in the California case by early April and suggested that the court might want to review both cases to understand "the range of testing programs likely to be affected by a ruling" on such programs.

NTEU President Robert M. Tobias said the high court's eventual decision in the Customs Service case "should clarify the constitutional boundaries of drug testing for federal employees and, we hope, destroy Reagan's plans for wholesale testing of the federal work force."

The justices also agreed to decide the constitutionality of a California law prohibiting a man from presenting evidence to prove that he is the biological father of a child born to a married couple.

The court said it will hear arguments next year that the law, similar to those in several other states, improperly creates a conclusive presumption that the child's father is the wife's husband.

The case, Michael H. and Victoria D. v. Gerald D., involves an appeal by Michael Hirschensohn, a Los Angeles businessman, who claims that he is the father of Victoria Dearing, 6. Hirschensohn contends that he and Carole Dearing had an affair during which the child was conceived.

Hirschensohn, who filed suit in 1982, claimed that Dearing told him that the girl, born in May 1981, was his child and that blood tests performed on the three show a 98 percent probability that Hirschensohn is the biological father.

Hirschensohn and Carole Dearing lived together occasionally until April 1984, when she and Gerald Dearing reconciled in New York, where the couple lives with a second child. Hirschensohn and the girl's court-appointed attorney petitioned in 1984 for visitation rights.

A California appeals court said Hirschensohn could not present his claims on paternity because the state had determined that, "given a certain relationship between the husband and wife, the husband is to be held responsible for the child, and that the integrity of the family unit should not be impugned."

In other action, the court let stand a ruling that the Fourth Amendment forbids Illinois law-enforcement officials from searching, without warrants, the quarters of employees who live and work at Illinois race tracks. The case is Schmidt v. Serpas.