The House yesterday dealt a blow to the Reagan administration's foreign trade policy by approving an amendment that bars new investment in racially segregated South Africa by U.S. companies or individuals.

The measure, offered by Rep. William H. Gray III (D-Pa.), was a rider on a bill reauthorizing the Export Administration Act of 1979--the federal law that controls the sale of U.S. goods and technology to foreign countries. The bill passed on a voice vote.

In addition to Gray's amendment, the House also approved a proposal by Rep. Stephen J. Solarz (D-N.Y.) to prohibit the importation of South African Krugerrands, or any other South African gold, into the United States.

Solarz's amendment to the reauthorization bill, which now goes to the Senate, would also bar most U.S. bank loans to the government of South Africa. Only loans for health, housing and educational purposes--which can be used on a non-discriminatory basis--would go to South Africa under Solarz's measure.

The administration steadfastly has opposed punitive restrictions on U.S. trade with South Africa, preferring, instead, to pursue what it calls a policy of "constructive engagement." That means, in the administration's view, trying to alter South Africa's treatment of its black majority through international good will.

Both Gray and Solarz said yesterday that the Reagan approach has failed.

The South Africa question sparked the most intense debate on the reauthorization of the export act, which has been under intermittent consideration in the House for several weeks.

The law had expired Oct. 14, forcing the administration to impose interim emergency rules to prevent the export of high-technology U.S. products to the Soviet Union and its allies.

The administration also opposed moves to limit presidential authority over the export of goods in short supply or to stop the export of goods produced by overseas subsidiaries of U.S. companies.

On those issues, the administration seemingly broke even in the House version. A proposal to force the White House to seek congressional approval before the president imposes export controls over existing trade contracts was defeated last week on a 237-to-172 vote. But the House turned back the administration's effort to lift restrictions on the president's authority to block exports by U.S.-owned offshore companies.

The bill approved yesterday also includes an amendment to close a loophole in U.S. law that allows the administration to grant export licenses for the sale of high-technology goods to countries that have not signed the Nuclear Non-Proliferation Treaty.