Two years ago Rabbi Mitchell Wohlberg surveyed the near-empty sanctuary of the Beth Sholom synagogue in northwest Washington and realized that drastic measures were needed if the synagogue was to survive.

Only one-fifth of the seats in the ornate sanctuary were occupied during sabbath services.The membership of the congregation was then overwhelmingly middle-aged or older. The religious school, whose classes for the young were once so large that the city had had to assign a policeman to handle traffic at th end of classes, had a total of enrollment of only 14 students.

"We were stagnating," said Rabbi Wohlberg.

The problem was that in many cases the younger members of the congregation were moving to the suburbs, away from the traditional Jewish neighborhoods, and they were taking their children, the lifeblood of the congregation, with them.

To remain in Washington would mean the congregation might eventually wither away, while moving the temple to the suburbs would mean leaving the faithful older members behind in Washington.

Rabbi Wohlberg and the elders of the congregation took a gamble. They built a religious school and chapel in the Potomac-Rockville area of Montgomery County on Seven Locks Road - a sort of branch synagogue - while keeping the old synagogue in Washington.

Today the gamble has paid off. Overall, the population of the synagogue's religious school has soared to 10 times what it was two years ago, and the membership of the congregation has increased by at least 10 per cent.

"Now there is a general feeling of Beth Sholom's being on the upswing, of being alive and well," said the rabbi with a contented smile.

Beth Sholom is not eh only local synagogue to adopt the experimental strategy in the face of migration patterns and drastic changes in religious lifestyles.

Washington Hebrew Congregation, the District's oldest and largest Reform synagogue, which has held suburban after-school Jewish education classes in Montgomery County schools for four years, is building a $3.5 million stallite center in Potomac.

Last fall, Temple Sinai in North-West opened a similar school in rented church facilities in Gaithersburg and Olney and immediately experienced a 10 per cent growth in the number of students. For several years, Adas Israel, the District of Columbia's most prestigious Conservative congregation, has offered pre-bar mitzvah classes in Montgomery County for a portion if its youths.

Rather than moving completely to the suburbs as two temples have done since 1970 - B'nai Israel and Southeast Hebrew Congregation - they chose to remain in the city but serve the suburbs, too.

"We decided to serve our congregation as opposed to biting our nails" about the future, said Adas Israel's principal, Joseph Bruckenstein.

More than half the area's 120,000 Jews and 28 of the 46 synagogues are located in suburban Maryland. Ten of the temples are in D.C. and eight in Virginia.

Synagogues, traditionally the centers of Jewish communal life, are being disrupted by individualistic social impulses of America in the 1970s. At the same time, they are faced with mounting costs that have discouraged new members, the drifting of some formerly active members to other Jewish community causes, anti-institutionalism and the tendency of many young families to delay synagogue affiliation until their children need Jewish education.

An estimated one-fourth of the nation's synagogues are on the verge of bankruptcy and hundreds have closed or moved to outer suburbs and sold their downtown buildings to churches. In Greater New York, with the country's largest Jewish community, the number of synagogues has decreased one-third in 20 years, and only 10 per cent of the Jews living in Manhattan have affiliated with temples, according to a recent report by the Jewish Telegraphic Agency.

Older urban congregations are particularly hard-pressed by these developments because they lack the influx of youthful members, who are settling in the suburbs where they believe they can be assured of quality education and where they can afford housing.

"The trend seems to be toward greater self-definition of the synagogue as a service center, rather than the cornerstone of a community or number of communities," said George E. Johnson, research director of the Institute for Jewish Policy Planning and Research in Washington in a study of the phenomenon.

The situation is even more aggravated in Washington, according to Johnson, because the local community, which has grown from 20,000 to 125,000 since World War II, lacks the deep ethnic roots of older settlements in the eastern U.S.

Syd and Ilene Schneider, who are in their early 30s, are typical of the yound Jews living in the suburbs. In 1975, when their older daughter was ready for Hebrew school, they "took a chance" and enrolled her in Beth Sholom's new suburban facility in Potomac even though they were not Orthodox.

"Then we got caught up in Beth Sholom and taken in by the newness and youngness of it," Mrs. Schneider explained. They joined Beth Sholom the same year and became part of the temple's leadership.

In their five years in the Washington area, the Schneiders had not been attracted to any of the synagogues they attended occasionally. The temples were either too big or too expensive for their tastes, and for the Schneiders, who were not accustomed to regular attendance, such considerations were sufficient to delay their synagogue commitment.

"We never put that much time and effort into our religion," said Mrs. Schneider, who was reared in New York City. "We knew who we were. But when our daughter began asking questions, like why she couldn't have a Christmas tree, then what was in the back of our minds suddenly moved to the front. We want them to know their very rich heritage."

Beth Sholom was appealing, she added, because it was "small enough, not too established, and if we were willing to work we could be the establishment." In addition, its attitude about Orthodoxy was not so strict that they, as Conservative Jews, would feel uncomfortable.

"Not in our wildest dreams did we ever think we could be going to synagogue every sabbath," she added.

The considerations of Jean and Robert Fleming in Olney were different. They wanted to join a District of Columbia synagogue because they believe they are more "progressive" than those in the suburbs. "But we could not possibly consider driving 45 minutes each way during rush hour" for daily children's activities," Mrs. Fleming said.

When Temple Sinai's school in Olney opened, last fall, the Flemings enrolled their three sons and joined the District temple on Military Road NW, where they can drive during nonrush hours for adult programs and worship.