Defense Secretary Caspar W. Weinberger said yesterday the United States and its allies may send more military forces to the Persian Gulf "if the situation continues" and warned that U.S. forces would not be reduced substantially until the Iran-Iraq war ends.

Weinberger, in a 2 1/2-hour appearance before the Senate Foreign Relations Committee, waffled on U.S. policies for protecting commercial shipping in the gulf, a sensitive political and military issue. He first told senators that naval escorts would provide protection for any U.S.-owned ship, even those flying flags of other nations, but later said those vessels would be given military protection only if they fly the American flag.

He also said U.S. military forces would respond to requests for assistance from any ship that is attacked in the gulf, but declined to specify what type of help the military would give, saying that he wants to keep the details out of Iranian hands.

A Pentagon official later said Weinberger was referring to "humanitarian aid," not military aid.

The policy issues have become increasingly important after last week when an Iranian Silkworm missile hit a U.S.-owned, but foreign-flagged ship in Kuwaiti waters and another Silkworm hit a Kuwaiti vessel flying the American flag in the same area. In response to the second incident, the U.S. Navy demolished a mid-gulf oil platform the Pentagon says Iran used for military operations and destroyed communications equipment on another platform.

Weinberger said that while the United States has 32 warships in the gulf region and U.S. allies have about 40 combatants there, "if the situation continues, we all may have to do more."

Asked by Sen. Paul S. Sarbanes (D-Md.) what would bring a return to a pre-escort force of a half-dozen vessels in the gulf, Weinberger said:

"Basically what would have to happen is you'd have to get some stability in the gulf, probably the ending of the Iran-Iraq war, certainly ending the tanker war, so that there would be no longer not just a suspicion, but a well-founded judgment, that nonbelligerent commerce will no longer be attacked by Iran."

He added, "It may well be {that} as allied strength comes in, we may be able to make some reduction."

Sarbanes also asked whether the United States is aiding Iraq in its seven-year war by protecting vessels of Kuwait, an Iraqi ally.

"It may have that effect," Weinberger said. "That's not the intention and not the direct effect. What we're doing . . . is to make sure this international commerce, American ships overseas, gets through. That may indirectly from time to time benefit one country or another, but that's not the purpose and I don't think the effect is all that direct."

Pentagon officials, meanwhile, said that the newest addition to U.S. gulf forces is a team of five trained bottle-nosed dolphins requested by the Middle East Force commander "to provide underwater surveillance and detection capability."

Pentagon sources said the dolphins will be used for mine-hunting and detection of underwater divers and swimmers.

Sources said the animals, which will be housed in large shipboard tanks, were sent to the gulf to "add a measure of security" to U.S. forces as well as to test the dolphins in "a realistic environment."

The Navy has been experimenting with dolphins, Beluga whales and California sea lions since 1962, according to Navy officials. About 150 naval and civilian employes train the animals at four navy facilities to operate with two mobile explosives ordnance disposal teams, officials said. The five dolphins, which arrived in the gulf Oct. 13, were trained at a Navy research laboratory at Point Loma near San Diego, officials said.