All military recruits must be tested for drug use before being sworn into the Armed Forces under a little-noticed amendment to a military authorization bill, a Pentagon spokesman said yesterday.

Starting in June, anyone who fails a urinalysis test will not be allowed into the military, said Maj. David Super, a Defense Department spokesman.

The requirement, added to an extensive program of random urinalysis of people already in the military, was proposed by Sen. Ernest F. Hollings (D-S.C.) as an amendment to the defense authorization bill which President Reagan signed into law Dec. 4.

Some defense officials oppose mandatory testing, arguing that current programs keep drug use below civilian levels and that the new tests will add costs at a time when the military budget is being cut, according to The New York Times, which reported the new requirement yesterday.

The law calls on the Pentagon to draw up a comprehensive testing program within 45 days and to implement it within 180 days of Dec. 4.

"We are marching along here to put the plan into effect by the deadline," Super said.

Under the current system, the Army, Navy, Air Force and Marines have their own programs to screen recruits within the first few months of service.

"Typically, during the first four months or so that a recruit is in the military, the chances are pretty good statistically that he or she will be tested regularly," Super said. Drug and alcohol statistics were not immediately available for all the services.

Another Pentagon spokesman, Navy Lt. Cmdr. Chris Baumann, said the Navy already has an extensive testing program.

"I came to Washington from the Naval Training Center in San Diego. And we were testing them for drug use while I was out there, over 2 1/2 years ago," he said. "The goal was that they would not be allowed to go into military service. The ultimate goal was to have them all tested before they got to the training center."

The new law specifically requires that recruits be tested before they enter the services. One section calls for "mandatory testing for drug, chemical and alcohol abuse. Before a person becomes a member of the Armed Forces, such a person shall be required to undergo testing for drug, chemical and alcohol use and dependency."