Federal funding aimed at discouraging sexual activity by teenagers is valid despite the "constitutionally troublesome" ways some religious groups spent the money, the Reagan administration told the Supreme Court Wednesday.

Saying that Congress passed the 1981 law "in response to grave social, economic and health costs" linked to teenage pregnancies, Solicitor General Charles Fried said, "In our view, the statute is plainly constitutional on its face."But Fried, the Justice Department's highest-ranking courtroom lawyer, conceded that some of the millions of dollars spent under the law each year may have gone to promote religion.

"I do not dispute that there may have been some departures" from past high court rulings on church-state relations, Fried said, adding that some of those departures are "constitutionally troublesome."

Janet Benshoof, an American Civil Liberties Union lawyer representing those who successfully challenged the law in a lower court, was asked by Justice Antonin Scalia whether Congress was empowered to authorize self-restraint among adolescents.

Benshoof replied, "Yes, but you can't do it by telling young girls to pretend that Jesus is their date."

At issue is whether the 1981 law impermissibly promotes religion because religious organizations obtain money under it.

The court's decision is expected by July.

Urged on by conservative Republicans, Congress allowed religious groups to obtain money for programs designed to prevent adolescent pregnancy by promoting self-discipline and to mitigate problems caused by premarital sex and teen-age pregnancy.

ACLU lawyers, representing those who challenged the law, said it "authorizes the use of federal funds to subsidize religious indoctrination as a means of opposing premarital sex, abortion and birth control for teen-agers."

A federal judge here agreed, and struck down the law last year.