A key figure in the investigation of alleged drug use on Capitol Hill has pleaded guilty to conspiracy to distribute cocaine and agreed to testify to a grand jury investigating allegations of drug use on Capitol Hill, sources familiar with the investigation said yesterday.

The agreement, reached Monday, came after weeks of bargaining between prosecutors and Douglas W. Marshall, 27, a former Capitol Hill page who was indicted last November by a federal grand jury here.

Marshall and Troy M. Todd Jr., 23, of Potomac, named in the indictment as the manager of a cocaine distribution ring, were first arrested in April 1982 in Marshall's Northwest Washington home after allegedly selling cocaine to an undercover D.C. police officer.

Their arrests sparked federal and congressional investigations of alleged drug use by congressmen and Capitol Hill aides. A third man arrested at that time, Robert A. Finkel, 30, who also worked on Capitol Hill, is now in the federal witness protection program.

Todd's lawyer, Stanley M. Dietz, said yesterday that Marshall's plea does not change his client's situation and that plea bargaining with prosecutors has broken off. Todd is not in a position to lead prosecutors to Capitol Hill figures, Dietz said.

At one point during the plea negotiations, Drug Enforcement Administration officials complained that prosecutors were being too lenient in proposed plea agreements. Yesterday, however, sources familiar with the situation said DEA officials were satisfied with Marshall's plea to one count in the indictment, a felony that carries a maximum penalty of 15 years in prison, because Marshall had agreed to cooperate fully in the investigation.

Judge Thomas F. Hogan, who accepted the plea, ordered Marshall to appear for sentencing in the case on Aug. 26.

So far, only one person has been sentenced after publicly pleading guilty in the case. He is Robert T. Yesh, a former employe in the House doorkeeper's office who pleaded in March to two misdemeanor drug charges and was sentenced in April to one year in prison.