The House yesterday gave President Carter one of the largest legislative victories of his presidency as it completed congressional action on a bill to create a new department of education.

The vote on the final compromise, creating a department with nearly 18,000 employees and an annual budget of $14 billion, was 215 to 201 -- a larger margin than was expected.

The legislation now goes to the president for his signature. The new department could legally be brought into being within the next few days, but it may be a few weeks before a transition team to be named by budget director James McIntyre actually works out all necessary plans.

Speculation turned almost instantly yesterday to the question of who will be secretary of the new department.

Names that have surfaced as possibilities over the past few months include Jerry Apodaca, former Democratic governor of New Mexico; Wilson Riles, superintendent of instruction of the state of California; Alan CamBell, head of the Office of Personnel Management (formerly the Civil Service Commission), and Mary Berry, now assistant secretary of health, education and welfare for education.

That department willl now become the Department of Health and Human Services. The education department is the second to have been created in the Carter administration. The Department of Energy was set up in 1977.

In winning passage of the bill, President Carter was carrying out a 1976 campaign pledge to the National Education Association, which subsequently endorsed him for president and is expected to do so gain, perhaps in the next few days. His arguments for the department included enhanced prestige for education in having a department and cabinet spokesman all its own, and the speeding up of educational decisions at the federal level, which he said could save $100 million a year or more by clearing out bureauaratic underbrush that Carter said had slowed up educational decision-making within HEW.

The president called passage "a significant milestone in my effort to make the federal government more effective. We will now have a single cabinet department which can provide the coherence and sense of direction needed" to manage billions of dollars in U.S. education funds.

He described the bill as "one of my highest legislative priorities of the past years" and said he was particularly grateful to House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.), who made a plea for final passage yesterday, to House floor manager Jack Brooks (D-Tex.) and to Senate floor manager Abraham A. Ribicoff (D-Conn.).

Lobbyists for the White House and the NEA, who had fought for the bill for two years, burst into cheer- and appause in the corridor leading to the House chamber as the tally mounted to 215 and the vote ended.

"This is a new day in American education," said an NEA lobbyist jublantly. However, lobbyists for the American Federation of Teachers, which had opposed the bill, were glum and silent at the other side of the corridor as the roll call finished.

Although the NEA, many education organizations and unions and groups opposed it. They feared it would break up the civil rights coalition by detaching education and would fragment services for the poor. Conservatives like Rep. John N. Erlenborn (R-Ill.) said the new department of education.

The American Federation of Teachers led the fight against it partly for these reasons and partly, some believe, for fear its arch-rival NEA would dominate the new department.

The new department will include all the major education programs now in HEW, such as elementary and secondary education aid, college aid, aid to the handicapped, vocational rehabilitation and vocational education, a major civil rights office, the Defense Department overseas school for children of service personnel and several other minor programs, plus some supervisory functions over Howard University, Gallaudet College, the American Printing House for the Blind and the National Technical Institute for the Deaf.

Other major education programs were left out (veterans' educational programs, job training, Head Start), partly for fear their inclusion would arouse too much opposition from "client" groups with established relationships with various departments and kill the bill.

When the initial version of the bill passed the House July 11 by a bare four-vote margin, it carried a set of antiabortion, antibusing and school prayer amendments. Even civil rights groups that favored the bill, such as the National Urban league and National Urban Coalition, said they would have to oppose it if these amendments remained in the final House-Senate compromise version.

Conferees dropped all those amendments before brining the bill back to the house and Senate for final approval. Eletion of the amendments reportedly helped pick up votes of some members who had previously voted against the House bill and enabled the final version to win by a wider margin than the bill that initially passed the House.