The Montgomery County Board of Education agreed after occasionally acrimonious debate early yesterday to a budget plan that is expected to result in the laying off of 39 teachers and will eliminate one of the school system's five area administrative offices.

The plan is a compromise among the board's conservative and liberal members on how to absorb a $5 million cut by the County Council in the board's $314 million budget proposal.

The four-member conservative school board majority fought vigorously to keep 45 secondary school teachers by shifting funds from the area offices. Last week the conservatives succeeded in restoring 10 elementary school teaching positions that were to be cut.

The board's three liberal members plus Superintendent Edward Andrews sought more time in planning a reduction in the number of area offices.

Under the compromise, one area office will be eliminated by next Jan. 1, but the personnel affected will be guaranteed salaries through the end of 1981. Fifteen of the secondary school teaching positions cut by the council will be retained to help keep down class size in larger high schools.

The conservatives had hoped to eliminate one area office immediately. Andrews told them that without council approval they could cut only enough positions in one area office to pay the salaries of nine teachers. Andrews also said he would be "inclined to refuse" a board order to serve immediate notice on area office employes.

About 300 teaching positions were eliminated from the budget for the next school year, most through atriions. The 39 who face layoffs are all in their first or second years.