TOKYO, JUNE 29 -- U.S. Defense Secretary Caspar Weinberger said today that the United States and Japan will work together to keep an edge over the Soviet Union in antisubmarine warfare capability despite Soviet purchase of Japanese machinery that can be used to make quieter craft.

"The damage done to our mutual security was of course significant," Weinberger said. "There's no question that the ability for the Soviets to run their submarines in a much quieter fashion and therefore make them more difficult to detect has been attained . . . and that is a serious loss."

Toshiba Machine, a subsidiary of the electronics giant Toshiba Corp., has been accused of selling the Soviet Union sophisticated milling machinery capable of manufacturing super-quiet submarine propellers.

Japanese officials said the sales, between 1982 and 1984, violated Japanese law.

Two Toshiba Machine executives were arrested and the firm has been barred from exporting any products to communist countries for one year.

Weinberger said he was encouraged by assurances from Prime Minister Yasuhiro Nakasone that Japan views the case seriously and has taken steps to make sure it does not happen again.

"We will simply have to try to make sure that in working together with our mutual talents and capabilities and energies we keep a lead over the Soviets in antisubmarine warfare," Weinberger told a news conference before flying home at the end of a three-day visit to Japan.

"We agreed to strengthen, improve and maintain the antisubmarine capabilities which we had, which is extremely important to maintain under the treaty of mutual cooperation and security," Weinberger said.

He refused to spell out what measures are planned.

Weinberger called the strengthening of such capabilities "a matter of vital importance to the security of Japan, obviously, and of vital importance to the security of the United States and indeed of the Free World."

Weinberger also met today with Foreign Minister Tadashi Kuranari and Defense Agency Director Yuko Kurihara and urged them to choose a U.S.-made jet fighter as Japan's next-generation fighter plane. The Japanese are considering developing their own fighter.