Robert White, former U.S. ambassador to El Salvador, charged yesterday that he has been forced out of the career foreign service because he opposed the Reagan administration's "ready-made doctrine" of military activity in that country.

White's ouster came as the State Department, in another sharp departure from the Carter administration's Latin American policy with which the ambassador had been associated, announced that Argentina's president-elect, Lt. Gen. Roberto Viola, has been invited to have a private visit with President Reagan here next week.

White, speaking to reporters before a House Foreign Affairs Committee hearing on El Salvador, disclosed that he has received a letter from the State Department "saying there is no other assignment and out you go."

"In my judgment, I'm being fired for my views," White said. After being removed from his embassy post by Secretary of State Alexander M. Haig Jr., White testified before Congress that the greatest danger in El Salvador comes not from leftist, insurgents, as the administration contends, but from rightist forces allied with that country's U.S.-supported military.

The State Department confirmed that White was notified last week that he would be retired as of May 23 under a provision of the Foreign Service Act applying to officers who complete presidential appointments, such as terms as a U.S. ambassador. These officers, according to the act, must receive a new assignment within 90 days or retire.

White is being retired because it is "not forseen" that a mutually acceptable new assignment will be found, a State Department spokesman said.

In his statement to the House panel, White said:

"If you have -- as this administration had -- a ready-made doctrine which asserts that the solution for El Salvador lies with the introduction of large qualities of armaments and military advisers, then your first priority becomes the removal of an ambassador who may complicate the application of your doctrine."

In announcing that Viola will meet with Reagan, Haig and Vice President Bush, State Department spokesman William Dyess publicly underscored the break with former president Carter's human rights policy.

Dyess said, "We want good relations with Argentina. Any abnormality in relations is due to a large extent to the public position this country took regarding human rights practices in that country."

Echoing a line stated by administration officials with increasing frequency, Dyess said public criticism of human rights violations will be reserved largely for "totalitarian" countries such as the Soviet Union, since their actions rarely come into public view.

By contrast, he said, authoritarian regimes such as those in Argentina, were the disappearance of thousands of people has been reported extensively, are comparatively open to public scrutiny.