PRESIDENT REAGAN'S crusade against the Soviet gas pipeline is working out badly for American national interests. It was supposed to be a test of wills between East and West. Instead, it's turning out to be a test of wills between the United States and its European allies. Far from punishing the Russians for imposing martial law in Poland, it's giving them the only foreign political advantage that they've been able to extract from the whole Polish affair.

Three gas compressors, built in France by the French subsidiary of Dresser Industries, are about to be loaded onto a Soviet ship. The Reagan administration threatens penalties against Dresser if the compressors go. The French government threatens criminal prosecution of the subsidiary, Dresser France, if they don't go. The French will win this one, since the equipment is in their country. The United States has let this affair degenerate into a highly public effort to impose its foreign policy on France. The French aren't likely to lose that one, either.

Mr. Reagan wanted to express American outrage at the suppression of Solidarity last December and to try to force the Soviet Union to relax it. He was not wrong about that. In addition to all of his earlier arguments against the pipeline, and for the embargo, there are now reports that the Soviets are using slave labor from the prison camps to accelerate construction. No one can claim to be surprised if those reports turn out to be true. But you do not have to like the pipeline deal, or martial law in Poland, to believe that this campaign by Mr. Reagan has strayed dangerously far from its original purposes.

A succession of American administrations has had a lot of experience with embargoes. It all adds up to a simple rule. They can be quite effective when they are supported by a wide international consensus. The West has run quite successful embargoes of the Soviet Union, and certain other countries, involving equipment of strategic importance that touches everybody's security. But where there is no agreement on strategic importance, the embargoes always fail. The pipeline embargo belongs in the second category.

As it is seen from Europe, the issue is no longer one of relations with the Soviets. It's now a matter of the Europeans' national sovereignty. The harder Mr. Reagan presses the French, the British, the Germans and the Italians, the harder each of those governments will resist.

What's needed now, and quickly, is a legal solution in the slippery sense of the term. The Dresser case needs to be wrapped heavily in verbiage and bundled off to an obscure tribunal somewhere for learned people to pore over and adjudicate, not very quickly, while tempers cool. That would give the administration a chance to reconsider its position and come up with tactics that, unlike the present ones, might promise to create more embarrassment for the Soviets than for the United States.