Mayor Marion Barry held out little hope yesterday that the city can quell its current epidemic of heroin trafficking unless the federal government "gets tough" with foreign countries that produce poppies and harbor international drug dealers.

Barry vowed at his monthly press conference that the city will launch a vigorous "spring offensive" against heroin and PCP dealers once again and also plans to fund drug treatment and education programs. But he said that he and other big-city mayors are at a loss to figure out what else to do to stem the treacherous drug tide.

"It's a war that has no ending to it," Barry said. "You move people from 14th and W streets, they go to Ninth and U . . . . The ultimate solution is for the federal government to get tough with the market coming from Iran, Afghanistan and Pakistan. To get tough with Colombia, to get tough with Mexico and to get tough with those other major suppliers of hard drugs in this country."

On another topic, the mayor said he will sign the $2.3 billion fiscal 1986 budget approved by the City Council Tuesday. Barry said he can go along with the council's decision to reduce his overall budget proposal by $1.2 million and to make a total of $30.3 million in spending shifts.

He also sharply criticized the Justice Department's recent court challenge to the D.C. Fire Department's affirmative action plan for promoting minorities, and predicted "a long, protracted legal battle."

The District's mushrooming drug problem dominated the press conference, in the wake of the heroin overdose deaths of nine persons in a single weekend and an extraordinary speech at Spingarn High School by the Rev. Jesse L. Jackson, during which about 100 students stepped forward to acknowlege they had used drugs.

Law enforcement officials and experts on drug abuse say the District has become a major center of heroin trade and has a death rate from heroin overdoses that is far out of proportion to the city's size. Washington is home to an estimated 12,500 addicts, city officials say, and D.C.police have identified 20 locations throughout the city where heroin is bought and sold openly on the streets.

Barry disclosed yesterday that the police department, with the consent of the school system, has assigned undercover agents to some schools in an effort to ferret out drug dealers. He also said that he and Jackson plan to make additional appearances at city schools to try to persuade students to give up or stay away from drugs.

"Things have gotten so bad that you have 11- and 12-year-olds who are out on the corners now selling PCP," Barry said. "We're in an epidemic. I wish this community would rise up against this epidemic to assist us. It's not the government's responsibility to do all of this. This community has to tell us where things are going on."

The mayor also warned that society is producing what he described as a frightening generation of young people who have been raised on violent television programs and who are exposed every day to drugs and street crime.

"They're not afraid of death, not afraid of guns, not afraid of nothing," he said. "We're in a dangerous age. We're going to have to regenerate our spirits and our spiritual values and try to compensate for that."

Barry told reporters that he intends to devote much of the next six months to dealing with criminal justice and corrections matters. Perhaps his biggest headache is the problem of crowding at Lorton Reformatory and the D.C. Jail.

The mayor said earlier this week that he is "unalterably opposed" to building a federally financed prison on a seven-acre site in Southeast Washington. Yesterday he refused to discuss the prison proposal further and referred all questions to City Administrator Thomas Downs, who will serve as the city's point man on the prison project.

He also expressed little concern for the nearly 100 inmates at the D.C. Jail who recently were abruptly transferred to federal prisons as far away as Terre Haute, Ind., and Duluth, Minn., with little warning to them or their families.

"These are people who have been convicted of crimes, and jails are not palaces," he said. "And we have the authority to take them anywhere that the federal Bureau of Prisons will take them.

"We're not going to have to notify everybody everywhere," he added. "We're not a convenience store where you have to let everybody know what's convenient. You take them [prisoners] out any time you want to."