Soviet leader Mikhail Gorbachev put an end to speculation that the current round of East-West spy swaps might be extended to include Nobel Peace Prize winner Andrei Sakharov today, saying the dissident physicist had committed "acts punishable by law."

In an interview to be published in the French Communist Party newspaper L'Humanite today and released here by the Soviet news agency Tass, Gorbachev said flatly that Sakharov, a distinguished physicist, "still has knowledge of secrets of special importance to the state and for this reason cannot go abroad."

It was Gorbachev's first public justification of the treatment of Sakharov, a leading figure in the Soviet human rights movement who has spent six years in internal exile in the city of Gorki.

Sakharov was sent into exile in January 1980, shortly after criticizing the Soviet invasion of Afghanistan, without being tried, convicted or sentenced. Subsequently, Soviet officials have said his term in Gorki was imposed in accordance with a "special act," although this never has been published.

Gorbachev, who was trained as a lawyer, said the measures taken against Sakharov are "in accordance with our legislation." He said that Sakharov, a member of the Soviet Academy of Sciences, is continuing his work in Gorki and that he is "in normal health."

Gorbachev has been asked publicly about the Sakharov case before, but he never has answered directly. In a previous interview with French television last fall, he justified the treatment of Anatoly Scharansky, a dissident serving 13 years in prison and labor camp, but ducked a question about Sakharov. Scharansky is expected to be released as part of an East-West spy exchange next week.

By dealing directly and openly with the Sakharov case, Gorbachev left little room for hope that its status will change.

In the interview, which was to be published this morning in L'Humanite, Gorbachev also took the offensive on criticism of the Soviet treatment of Jews, and on charges that political prisoners are held in Soviet jails.

"We do not put people on trial for their convictions," said Gorbachev, while noting that a state has the right to protect itself against subversion and treason. "A little more than 200 people are serving sentences for all crimes of such a kind in the U.S.S.R.," he said.

He said campaigns on behalf of Soviet Jews were "nothing short of hypocrisy" and "a veritable act of psychological warfare against the U.S.S.R."

Gorbachev also defended Soviet censorship, although he took to task those in Soviet society who do not tolerate criticism.

He noted that some form of censorship exists in all countries and cited the example of books by Dostoevski, Hemingway and Dickens being banned by conservative groups in American school districts.

On foreign policy, Gorbachev said that Washington, by pursuing the "Star Wars" program, "deliberately aims to thwart the current [arms control] talks and erase all existing arms control agreements."

While attacking President Reagan's concept of a strategic defense, Gorbachev did strike a positive note on U.S.-Soviet relations when he said "a certain change in the political atmosphere already has made itself felt."

The appearance of Sen. Edward M. Kennedy (D-Mass.) on Soviet television news tonight, reading a prerecorded message, was seen here as another example of the visible warming in U.S.-Soviet relations. Kennedy left Moscow today after a three-day trip during which he met with Gorbachev.

Still, Gorbachev emphasized caution in assessing the developments since his summit meeting with President Reagan in Geneva.

Since November, the Soviet Union has continued to hit hard at the Star Wars program as the key to the arms control problem. Gorbachev, in the interview, used the space shuttle tragedy as an example to show that sophisticated machinery can be dangerous, despite its intended purposes.

[An editorial in Pravda Friday attacked Reagan's State of the Union address in the strongest such criticism in the Soviet media since the summit, the news agency Reuter reported. Pravda said the address was "a manifestation of the rapacious, egoistic ideology of the most conservative, right-wing groupings in the country."]