Secretary of State George P. Shultz and Soviet Ambassador Anatoliy Dobrynin agreed yesterday to have the commanders of U.S. and Soviet forces in Germany meet to discuss new measures of preventing such incidents as the fatal shooting of a U.S. Army major by a Soviet sentry in East Germany last Sunday.

NBC News reported that the meeting will take place next week in East Germany.

The agreement, reached during a 70-minute session at the State Department, was described by Dobrynin and a spokesman for Shultz as intended not only to forestall such use of force in the future but also to ease tensions that followed the killing of Maj. Arthur D. Nicholson Jr.

The major was buried yesterday at Arlington National Cemetery.

There were signs that some officials in the Reagan administration want a tough response to the Soviets, but the agreement between Shultz and Dobrynin appeared to reflect a decision by both governments not to allow Nicholson's death to interrupt efforts to improve relations on a broad range of issues, including the arms talks in Geneva and possible summit meeting between President Reagan and new Soviet leader Mikhail Gorbachev.

Nicholson, an Army liaison officer operating in East Germany, was shot when the sentry accosted him near a garage-like storage shed. U.S. officials maintain that he was permitted to make observations and take photographs under the longstanding ground rules of what they called a "cat-and-mouse game" played by U.S. and Soviet intelligence-gathering teams in East and West Germany.

The administration indicated last Wednesday that if the Soviets did not take constructive steps to guard against further incidents, the United States would be forced to consider retaliatory measures. However, a spokesman for Shultz said yesterday's agreement was the kind of response the United States wanted.

"We are very pleased with this agreement to have our commanders in chief get together to discuss this matter and to ensure that there will be no repetition of such episodes," Mark Palmer, a deputy assistant secretary for European affairs, said on Shultz's behalf.

Dobrynin told reporters that "the commander in chief of the group of Soviet forces in Germany and the commander in chief of the U.S. Army in Europe and their representatives would establish contacts to discuss questions related to closing this entire matter and also to consider possible measures to prevent incidents with the members of the intelligence liaison missions."

However, a more combative tone was taken earlier yesterday by Defense Secretary Caspar W. Weinberger. Returning here from meetings in Europe, Weinberger told reporters on his plane, "I don't think the subject is finished by any means." While stressing that the United States was unlikely to do anything that might scuttle hopes for a summit meeting, Weinberger said the administration was studying "other means of conveying to the Soviets our repulsion and supreme anger" over the killing.

State Department officials pointed out that when Weinberger made his comments, he probably was unaware of what had happened at the Shultz-Dobrynin meeting. They also said there was unanimous agreement in the administration that Nicholson's killing was "a reprehensible and inexcusable act."

"There is no intention to cool this off just for the sake of avoiding trouble, no intention to sweep it under the rug," said a senior State Department official who asked not to be identified. "What we wanted was a responsible Soviet response that gives promise of preventing these things from happening again, and we think we got it in the meeting with Dobrynin."

Immediately after Nicholson was killed, top administration officials decided on a strategy that involved strong condemnation of the Soviet action and a signal to Moscow that the United States would regard Moscow's response as a test of how the Soviets intend to manage relations with the United States in the Gorbachev era.

There continues to be some uncertainty as to what Nicholson was doing when shot. At one point, officials said at a background briefing that Nicholson was trying to take photographs through a window in the shed. They also said the Soviets had designated the area as off-limits to U.S. liaison personnel but had lifted the restriction in February.

But the next day other officials said that an interview with Nicholson's driver made clear that the officer neither reached the shed nor took a picture. These officials also contradicted the statement that the site recently had been designated as a restricted area.