Two junior high schools in the District and two high schools in Northern Virginia were among 144 schools rated yesterday as among the nation's best by a federal commission that earlier this year decried the erosion of excellence in the country's public schools.

Brookland Junior High School in Northeast Washington and Jefferson Junior High in Southwest, T.C. Williams High in Alexandria and George Mason Junior-Senior High in Falls Church were selected during a search organized by the U.S. Department of Education.

Maryland officials declined to participate in the competition, saying the contest discriminated against inner-city schools. Fairfax County, which has the largest public school system in the Washington area, also decided against participating after state officials said the county could nominate only one school.

The four Washington area schools were chosen from 396 nominated by officials in 42 states and the District for having impressive records on such things as achievement tests and drop-out and attendance rates. The schools will be permitted to fly a special flag symbolizing their excellence and will be listed by the National Commission on Excellence in Education in a new report titled "America Can Do It."

"Our objective was not to name the best schools in America," Secretary of Education Terrel H. Bell said yesterday in announcing the 144 schools in a Whittier, Calif., ceremony with President Reagan. "Rather, we looked for those that are unusually effective in meeting the needs of their students."

The search for the best schools, called the Secondary School Recognition Program, was launched in January before the national commission released its controversial report calling for longer school days and years and better pay for teachers. The new listing also follows recent achievement test results that show standard scores improving in the District and Virginia schools. The commission acted "knowing that we need some role models," Bell said in a statement. "It is my hope that in spotlighting the qualities common to good public secondary schools, they can be adapted in other settings across the nation."

Maryland State Superintendent David Hornbeck decided not to involve Maryland schools in the competition, said spokesman Gus Crenshaw. Hornbeck wanted to preserve morale and harmony between the state's city and suburban schools. "When two good schools are compared, the school not chosen gets very bad signals," Crenshaw said.

District School Superintendent Floretta McKenzie said the selection of the two District schools indicate the success of the recent programs initiated in the system. "We believe we have excellent educational programs at both those schools," McKenzie said. "I believe we have some other good schools, too, and these represent the best of our education system."

The two Northern Virginia schools selected are the only senior high schools in their communities. T.C. Williams High principal Robert Hanley said the school's efforts to serve a widely diverse student body yet maintain a personal atmosphere helped earn it the honor.

It serves 2,500 students interested in subjects ranging from advanced calculus to auto repair. "I think they liked that idea," Hanley said yesterday.

Schools that earned the outstanding rating were first nominated by local school officials and then reviewed by a national panel of educators, parents and community leaders, according to Bell. A panel of education experts visited schools selected as finalists this spring before making the selections.

Among the criteria considered for selection to the list of the elite were 14 characteristics including order and discipline, clear academic goals, high expectations for students, community support, frequent homework, teacher efficacy and administrative leadership.