A 17-year-old youth testified yesterday that he engaged in several acts of sodomy as "a favor" to a Washington lawyer who represented him during juvenile court proceedings in the District of Columbia.

The youth was called as a key witness for the prosecution on the opening day of the trial of Roger H. Moore, the lawyer indicted by an Arlington County grand jury on charges of committing sexual improprieties with several teen-age clients. The trial is before an Arlington Circuit Court jury.

"Mr. Moore is on trial today because he breached a duty to his client," prosecutor William A. Nunn III said in an initial statement to the jury of seven women and five men. "The evidence will show that he used a 16-year-old boy to gratify his own sexual desires." The youth who testified yesterday was 16 at the time the alleged offenses occurred.

Moore's attorney, Thomas J. Harrigan, countered by accusing the prosecution witness of "committing baldfaced perjury." Harrigan portrayed the youth as a juvenile delinquent who committed burglaries, attemped suicide, used narcotics and contradicted himself in sworn testimony.

"He's fabricating this in order to get himself out of his own jam," Harrigan told the jury.

In the trial that began yesterday, Moore, 33, is accused of committing oral and anal sodomy with the youth, whom he represented as a court-appointed lawyer. The incidents allegedly took place at Moore's Arlington home in March and June of last year.

Moore, a George Washington University Law School graduate whose office is at 1511 K St. NW, has been indicted on several other sexual charges. These are expected to be the subject of later trials.

He is alleged in separate indictments to have committed sodomy with another 16-year-old youth last fall and to have sexually molested a 13-year-old boy in June 1978. Moore has pleaded innocent to all the charges. A trial on two sodomy counts has been scheduled for next Wednesday. No trial date is yet set on the other charges, according to court records.

The District of Columbia Bar initally asked the D.C. Court of Appeals to suspend Moore's license to practice law, but bar counsel Fred Grabowsky said yesterday that the request was withdrawn after Moore agreed not to represent juvenile clients. Any further disciplinary action by the bar depends on the outcome of Moore's trials, Grabowsky said.

Each of the four sodomy counts on which Moore went on trial yesterday carries a maximum penalty of five years imprisonment and a $1,000 fine. If convicted, Moore would probably face suspension of his law license as well.

Moore said yesterday that he is currently engaged in an active law practice.

The youth who testified yesterday said several incidents occurred at Moore's home, the first allegedly on the day when Moore was initially appointed to represent him in a D.C. Superior Court proceeding.

Asked why he did not object to the sexual act, the youth testified, "He promised me that he was going to get me out of St. Elizabeths," Moore had been appointed to represent the boy at a hearing dealing with his commitment to St. Elizabeths hospital for psychiatric observation, according to court testimony.

The youth told the jury of two other incidents on June 16 when he said he was invited on a motorcycle trip to Harpers Ferry with Moore. When Nunn asked the youth why he engaged in the sex acts, the boy replied, "As a favor."