A U.S. District Court judge in Baltimore has ordered the Communications Workers of America to refund to 18 employes a substantial portion of their union dues on grounds the money might have gone to political causes.

The National Right to Work Legal Defense Foundation, a longtime union adversary, termed it "the best decision we've ever had" on the issue.

Judge James R. Miller Jr. concluded that for the years since 1976, the union could not account satisfactorily for the expenditure of 79 percent of the $29 million in dues collected, leaving the possibility that this amount was spent on nonbargaining--or primarily political--activity.

Miller Friday ordered the union to refund 79 percent of dues paid during those years by the plaintiffs, all employes of the Chesapeake & Potomac Telephone Co. who are represented by--although they are not members of--the Communications Workers union.

Refunds to the 18 employes total at least $5,000.

The court also is expected subsequently to follow a recommendation by a court-appointed expert that would require the union to improve its accounting methods and to hold in escrow an amount sufficient to reimburse any other successful claimants.

A spokesman for the union said the ruling is not as significant as the Right to Work group suggests.

"We've been giving rebates to dues-paying nonmembers for seven years," he said. The court ruling would simply require the union to be "more accurate in our accounting and more lenient in taking the dues from those who don't want to be members," he said.

The union's right to collect and spend money for political purposes is not in question in the case,, the spokesman said.

Milller's ruling was in a 12-year legal battle waged by Harry Beck, a former phone company maintenance worker in Maryland who protested when union dues were used to support Hubert Humphrey in 1968.

This and other cases are aimed at setting limits on the kind of union activity that reluctant dues payers must support. Many of these workers are nonunion members required under the laws of some states to pay dues--or "agency fees"--as a condition of employment.

Reed Larson, head of the National Right to Work Foundation, said the ruling "will act as a deterrent to other union officials who now spend millions of dollars each year in compulsory dues for partisan political action . . . . " The organization, long an adversary of organized labor, provided free legal services to the plaintiffs. The court order requires that the union pay all court costs.