In a setback for the Reagan administration, a federal judge yesterday cleared the way for the NAACP Legal Defense and Education Fund and seven other legal and political advocacy groups to participate in the government's $120 million charity drive this fall pending a court decision on whether the organizations were illegally barred from the annual fund-raising drive because of their political views.

U.S. District Judge Joyce Hens Green issued a preliminary injunction that will allow the eight organizations -- the NAACP fund, Planned Parenthood, Puerto Rican Legal Defense and Education Fund, Federally Employed Women, Indian Resource Center, Lawyers' Committee for Civil Rights Under the Law, Sierra Club and Natural Resources Defense Council -- to solicit contributions from 4 million civilian and military employes during the 1986 Combined Federal Campaign.

Without indicating whether the agency will appeal the injunction, Office of Personnel Management Director Constance Horner said in a statement, "We look forward to the day when special-interest groups no longer use the courts and the Congress to impede the charitable impulses of federal employees."

A hearing on whether the charity regulations, issued by OPM, unconstitutionally discriminate against certain groups is scheduled before Green on Sept. 24.

The question of who should be in and who should be out has dogged the charity campaign for years, becoming even more heated during the Reagan presidency.

The administration has tried to reduce the number of organizations participating in the drive, arguing that having too many groups disrupts the federal work place and threatens the success of the fund-raising effort. However, officials of the organizations say their involvement increases overall contributions.

The Supreme Court last summer upheld new OPM regulations that in effect barred legal and political advocacy groups. But the court left it up to Green to decide whether the government improperly excluded the groups for political reasons.