A high-ranking Treasury Department official, in a strongly worded speech, yesterday warned U.S. trading partners they can expect stiff retaliation if they restrict free trade or provoke an export credit subsidy war.

The Reagan administration, despite its recent encouragement of the Japanese "voluntary" restraint of automobile exports, is committed to "pursue a policy of open markets," said Deputy Treasury Secretary R. Tim McNamar.

"We expect other nations to do the same," McNamar said. "If they do not, but instead resort to a variety of protectionist devices, impair our access to their markets or artificially undercut the competitive advantage of U.S. industries, we will not stand by idly."

"And I might add that our own bilateral decisions on trade issues have been and will continue to be based on our assessment of the overall practices of our trading partners," McNamar continued. "We will obviously feel less inclined to be free-trade purists with those who in fact are not opening their markets to our goods and services. We are pragmatists and judge a nation by its actions and practices, not its palaver."

McNamar also spoke harshly of that arrangement with the Japanese.

After listing free-trade barriers used by other countries, the deputy secretary said, "Indeed, even in my own country we have seen an example of brinksmanship bargaining that resulted in a voluntary restraint of trade as the choice of a lesser evil to ameliorate undeniably powerful political pressures."

McNamar's remarks, to be delivered to the Institutional Investors Conference in Cannes, France, were made available in Washington.

McNamar was particularly harsh toward countries subsidizing private firms' exports.