District of Columbia officials said yesterday they were caught off guard this week by indications that the White House will decide within three weeks whether to replace the top prosecutor here, U.S. Attorney Charles F. C. Ruff.

Mayor Marion Barry, who lobbied unsuccessfully to have his own choice named to the post when Ruff was picked, said he has "not focused" on the issue yet this time.

Barry declined further comment, but a spokesman said later that the mayor is "hopeful that the White House will consult him" before making a final decision.

When former U.S. attorney Earl J. Silbert was being replaced by Ruff two years ago, city Democratic leaders argued that they should have a strong advisory role in the naming of a new prosecutor. They lobbied the Carter White House for appointment of Togo West, who is black, arguing that such an appointment would be appropriate in a city whose population is 70 percent black.

But this time, there are no blacks among the candidates being seriously considered and neither the city nor the city's black legal community has lobbied the White House. The leading contenders are two former assistant prosecutors, Joseph E. diGenova, chief legal counsel of the Senate Rules Committee, and Paul L. Friedman, a partner in a Wall Street law firm.

At this juncture, I can tell you that that issue [race] has not raised its head," said White House Counsel Fred Fielding, the presidential aide most involved in the search for a replacement for Democrat Ruff.

The most telling difference from the situation two years ago is that the current administration is a Republican one and is expected to name a Republican to the job, which Fielding called "one of the most important" U.S. attorney posts in the country.

"I don't know of any push for a black U.S. attorney," said D.C. Court of Appeals Chief Judge Theodore R. Newman. "In fact, I doubt if any black Republican lawyer in this town is interested in it, and I'm reasonably sanguine that this administration will appoint a Republican."

Newman added that he has not even heard idle gossip about the issue. "I have heard nothing, not a mumbling word about it," he said.

District officials said the matter has been complicated by the failure of the Reagan administration so far to set up the kind of day-to-day communication with the city that existed during the Carter years. Relations got off on the right foot with Reagan inviting Barry to a number of social functions, the city officials said, but since then there has been little direct contact other than a series of brief meetings between Barry and a number of cabinet members.

The Reagan team has not assigned anyone to serve as a full-time D.C. liaison, although an aide in the White House Intergovernmental Affairs operation has been giving primary responsibility for contact with city officials. But on specific issues, different White House officials can be involved - like Fielding on judicial and prosecutorial appointments, for example.

"After the first social engagements we all said we'd just wait until things get in place," a high-ranking city official said. "But now it looks like almost nothing is in place." The official said that the White House has been preoccupied by the assassination attempt on President Reagan and the uncertain course of his economic package, making D.C. affairs a low priority.

"It's not really a rebuff, but we aren't over there every day with a list of names [for various appointments]," the official said. "Then again, nobody has told us not to come over. It's just a lack of movement."

During the 1979 search for a successor to Silbert, District officials and black lawyers united around West as a candidate. This time, however, there has been little or no discussion among black lawyers about a candidate for the job, local lawyers say.

"I'm not aware of any concerted effort" to support a black candidate, said Thomas Duckenfield, Superior Court clerk and president of the predominantly black Washington Bar Association. Duckenfield added, however, that he anticipated there would be some discussion in the near future.

Sources indicated this week that the Reagan administration, which has generally decided to appoint new Republican-backed prosecutors, began to focus attention on Ruff's future after he personally took over the prosecution of John W. Hinckley Jr., accused of shooting Reagan on March 30. Fielding described the D.C. post yesterday as "one of several" around the country that he is working on.