The U.S. government may erect trade barriers against Japan if that country doesn't improve investment opportunities for American firms, Undersecretary of Commerce Robert E. Herzstein warned yesterday.

Noting growing tension and uneasiness between the two countries over trade, Herzstein told a luncheon meeting of the Japan Society in New York that the U.S. government has the option of erecting these barriers when American firms are denied access to Japan or of making "rapid progress in achieving effective equal access to investment in Japan."

The influx of Japanese automboiles her and American automakers' small share of the Japanese auto market has been a hot issue with the Carter administration. Herzstein, however, didn't single out that trouble spot in his talk yesterday. The International Trade Commission soon will decide whether the importation of Japanese-built cars and light trucks should be restricted with quotas or tariffs.

Herzstein said the course the administration decides to take on any trade barriers to the Japanese depends "a great deal" on whether Japan's newly liberalized trade laws make investment by American firms easier.

"Equal opportunities for investment are in the long-term interests of both Japan and the United State," he continued. "We hope that is the course we are able to follow."

Japan's restrictive policies and attitudes include a "deeply ingrained preference" for Japanese goods over foregin ones and business relationships that depend more on longstanding loyalties and associations than on contractural arrangements, making it difficult for newcomers to break into the markets there.

Despite recent liberalization of some restrictions, the Japanese government still employes some reporting and other administrative requirements that Herzstein said "can operate to restrict American direct investment just as effectively as rules requiring prior approval."

As a result, Japan's alleged restrictive policies "are creating adverse reactions in the United States and may even threaten a political backlash," Herzstein said.