Defense Secretary Caspar W. Weinberger, seeking to erase any "shock . . . and doubt" left here by Carter administration plans to withdraw U.S. ground troops from South Korea, today pledged the "unswerving commitment" of the United States to keep its troops here and to help Seoul repel any new attack.

The defense chief, on his first swing through Asia since taking office, told reporters that the highest priority of his visit was "to underline the commitment that the United States has" and to show American appreciation for the way South Korea has shouldered the expensive burden of maintaining strong defenses in the face of a large military threat from the north.

Weinberger met this morning with South Korea's prime minister and defense and foreign ministers and then traveled north to the demilitarized zone that has separated this nation since the Korean War ended almost 30 years ago.

In a speech several hours later to hundreds of representatives from business, government and the South Korean press, Weinberger reiterated President Reagan's "full commitment to the security of the Republic of Korea." He also said U.S. plans call for "a substantial improvement in our military capability and assets in the region" and said he "hoped to do even better next year."

Meeting with reporters afterward, Weinberger said the buildup of American strength here was not a matter of greatly increased forces. Rather, it would involve replacement of older equipment by more modern F16 fighters, A10 attack planes, more ships including the battleship New Jersey, and patrol planes that will be coming to the Pacific as part of an overall U.S. fleet expansion.

On future aid, Weinberger said South Korea has been paying back its previous loans and is a good candidate for "somewhat lower" preferential interest rates for future loans. Seoul also has become a sizeable arms manufacturer and wants permission from the United States to export items such as ammunition, mortars, and artillery to third countries.

Weinberger came to Korea yesterday from Japan, a prosperous country that spends less than 1 percent of its gross national product on defense and one which Weinberger is trying to nudge into doing more. But Korea, with some 600,000 men under arms and spending 6 percent of its gross national product on defense, is clearly the biggest success story in Asia from the Pentagon's viewpoint.