A federal judge today ordered the immediate release from the Atlanta federal penitentiary of 381 Cubans who have spent more than a year behind bars wihthout being charged with a crime in this country.

But as soon as U.S. District Court Judge Marvin H. Shoob signs his order Thursday, Justice Department attorneys here are expecting word from Washington instructing them to ask the Fifth Circuit Court of Appeals to stay Shoob's order, bringing into doubt how many, if any, Cubans will be released after 14 months behind bars.

Assistant U.S. Attorney Douglas Roberto said he expected the government to ask the three-judge appeals panel to put Shoob's order on ice so it would not be effective until the panel has a chance to review it. He said the appeal will argue that Shoob had no authority to interfere in immigration policy set by the executive branch.

Yet the government today agreed to the release of 156 Cuban detainees, as soon as "suitable sponsors" can be found, because Attorney General William French Smith said he believes they do not represent a threat to society.

Roberto said a request for a stay would not interfere with the release of these detainees. Their release, approved by the Carter administration, was halted in April by the attorney general pending a policy review.

Art Brill, a Justice Department spokesman in Washington, said the government would appeal releasing the rest of the Cubans until their release is approved by the special review panel because "we feel there could be a number of criminals in that group."

Justice Department attorneys who have reviewed their files with lawyers for the Cubans said in court today that they no longer objected to the release of the 381 people covered in the judge's order because they are not thought to be dangerous.

These Cubans are among the 1,800 Shoob ordered released from the maximum-security prison here because their cases had been adjudicated favorably by an immigration judge or because they were being held solely for lacking entry papers to this country.

Shoob also ordered the government not to send any Cubans back to Cuba until he considers their political asylum requests at a hearing Aug. 28. The Reagan administration has indicated that it intends to return them to Cuba if Cuban President Fidel Castro changes his mind and agrees to take them back.

Dozens of Cuban detainees who have spent 14 months in prison still could be released as early as Friday, attorneys said, as soon as their medical check-ups are completed and arrangements are made for them to join relatives.

The government's pending appeal of the release order calls into doubt the fate of the remainder of the 381 Cubans. Shoob ordered their release as soon as the U.S. Catholic Conference, which has resettled thousands of Cuban refugees, can find them suitable sponsors or room in halfway houses around the country.

Gerry Wynne of the Catholic Conference said all the refugees could be resettled by mid-September. Assistant U.S. Attorney Robert Castellani said the government had objected to releasing the Cubans because they had not been cleared by a special review panel set up by Attorney General Smith.

In April, Smith halted 156 Cubans' release, approved by the Carter administration, pending his policy review. The government today agreed to free those Cubans because it now believes they are not dangerous.

Shoob also plans to review other categories of Cubans imprisoned for various crimes committed in Cuba to determine if they are releasable, or would present a threat to society.

Flanked by an American flag and rhododendrons, Shoob invited a dozen reporters into his spacious 19th-floor chambers in the federal building and enjoined the government from sending any Cubans back after a U.S. attorney said he couldn't promise the judge that the government might not try to send them back "as the opportunity arises."

"I'm convinced these people would not be welcomed back to Cuba," Shoob said. He has blistered the government for foot-dragging in its handling of the Cubans.

"I don't see how the government can deport these men without an entry permit and not send back the rest of the 125,000" Cubans who arrived on last summer's so-called Freedom Flotilla, he said.

Federal courts have ruled that deportable aliens have rights once they remain in this country and cannot be held for more than a few months without such detention becoming arbitrary imprisonment.