The Senate, over objections of the Defense Department, voted yesterday to require drug and alcohol tests for all volunteers before their induction into the military services and to permit members of the military to wear religious headgear, such as yarmulkes, or other religious apparel if it does not interfere with duties.

The drug test amendment, sponsored by Sen. Ernest F. Hollings (D-S.C.), was approved by voice vote. The religious apparel amendment, offered by Sen. Frank R. Lautenberg (D-N.J.), was approved 55 to 42.

The armed services now test new recruits for narcotics abuse after they are inducted. The proposed tests for "drug, chemical and alcohol use" would be conducted before a volunteer is inducted or a serviceman or woman is allowed to reenlist, Hollings said, making it substantially easier to reject or discharge the candidate.

The Senate rejected the religious headgear proposal last year, but adopted the measure as an amendment to the $302 billion defense authorization bill. The House has approved the proposal.

The Senate rejected, 48 to 46, an amendment by Sen. Jesse Helms (R-N.C.), which would have limited to 5,000 the number of people employed by foreign nations who are granted diplomatic immunity from criminal actions in the United States.

Senators have yet to act on a variety of other defense issues, including a proposal to require continued compliance with the unratified 1979 SALT II arms-control agreement, which President Reagan said will no longer guide his decisions on nuclear weapons numbers.

Reagan has said he will veto the bill if it limits proposed tests of the Strategic Defense Initiative (SDI), or "Star Wars" missile defense research project.

Lautenberg said his military-apparel amendment would permit wearing of "neat, conservative religious apparel" that would not interfere with military duties.

A superior officer could order the apparel removed if, in the officer's judgment, it affects military performance or discipline, Lautenberg said.

"It would permit one to observe one's faith while serving one's country," Lautenberg told the Senate. "It would affirm our religious diversity."

Opponents said the Pentagon opposed the proposal on grounds it could undermine discipline and uniformity in the armed services.

Sen. Frank H. Murkowski (R-Alaska) said the American Legion and other veterans' groups oppose the proposal.

"Religious freedom is not the issue," Murkowski said. "It is good and ordered discipline . . . the ability to enforce standards. Uniformity and cohesion is important."