The death sentences against a woman convicted of stabbing to death a motel owner in Cecil County, Md., and a man convicted of shooting to death two persons in a Baltimore County motel were affirmed today by Maryland's highest court. But the state's public defender said the legal fight to keep them from the gas chamber will continue for many years.

The state Court of Appeals rejected legal arguments that the cases against Vernon Lee Evans Jr. and Doris Ann Foster were mishandled during the trials.

Evans, 35, was convicted of shooting Scott Piechowicz and his sister-in-law, Susan Kennedy, in a Baltimore County motel in 1983. Prosecutors said that Evans was paid $9,000 by Anthony Grandison, against whom Piechowicz and his wife, Cheryl, were to testify in a federal drug trial. Kennedy was apparently mistaken for Cheryl Piechowicz. Grandison has been sentenced to death.

Foster, 40, was convicted of killing Josephine Dietrich, 71, with a screwdriver during a 1981 robbery of a Cecil County motel. Foster was sentenced to death in 1982, but the Maryland Court of Appeals overturned the conviction in 1983. The case was retried last year, and Foster was convicted and sentenced to death a second time.

Foster is the only woman among 21 people under sentence of death in Maryland. The number of inmates on death row in prisons around the state constantly fluctuates, however, as some win new trials or reduced sentences.

No death sentence has been carried out in Maryland for more than 20 years. When the Supreme Court struck down death penalty laws around the country in 1972, those under death penalty in Maryland were given life sentences. Maryland rewrote its death penalty laws in 1975, but nobody sentenced to death since then has exhausted appeals in state courts. When those appeals are exhausted, appeals in the federal courts could begin.

State Public Defender Alan H. Murrell, whose office represents both Evans and Foster, said attorneys will meet next week to decide the next steps for their clients.

Since she was sentenced to death, Foster has frequently charged that prison life is "inhumane," requested that her appeals be dropped and asked to be executed without delay.

During the summer, she and fellow death row inmate Annette L. Stebbing, 24, wrote Chief Justice Warren E. Burger asking to be sent to the state gas chamber. Stebbing was convicted with her husband of killing an Essex, Md., woman in 1981 and stuffing her body in a sewer.

But public defenders continued appeals for both women and, last Friday, Circuit Judge Albert P. Close of Harford County agreed to reduce Stebbing's sentence to life in prison, the same sentence her husband, Bernard L. Stebbing, had been given originally.