J. Jackson Walter, a real estate lawyer and an expert in public administration, has been appointed president of the National Trust for Historic Preservation, it was announced yesterday.

Walter is replacing Michael Ainslie, who resigned the post in May to become president and chief executive officer of Sotheby's Worldwide, the fine art and luxury real estate auction firm.

Walter, 43, served under presidents Carter and Reagan as director of the U.S. Office of Government Ethics. In that position, which he held from 1979 to 1982, Walter supervised establishment of a program to enforce federal conflict-of-interest laws in the executive branch.

For the past two years he has been president of the National Academy of Public Administration, a nonprofit corporation that has its headquarters here.

From 1976 to 1979 Walters was secretary of the Florida Department of Business Regulation. He was born in Philadelphia and received a bachelor's degree from Amherst College in 1962 and a law degree from Yale in 1966.

For a decade after his graduation he had a private law practice and worked for Land/Vest Inc., a rural land marketing and development firm in New England.

"Walter's experience in managing those government agencies and the nonprofit corporation in Washington, together with his background in land use and planning law and real estate development, makes him particularly well qualified to lead the National Trust," said chairman Alan S. Boyd in a formal statement at the trust's annual conference in Baltimore.

Walter is expected to concentrate on long-term planning, Boyd said, primarily the organization's five-year "strategic planning process."

The program's goals, according to Boyd, include "moving toward financial self-sufficiency, reaching out to new audiences with the message of preservation, and serving as an advocate for historic buildings before Congress, federal regulatory agencies and whenever needed in the courts."

One of Walter's immediate challenges will be to attempt to persuade the Reagan administration to stop its efforts to end federal funding of the trust and state historic preservation agencies.

For three years, Boyd charged, the trust has had to rally friends in Congress to reinstate these funds, most recently in a resolution that provides about $4.4 million for the trust and $21 million for state agencies during fiscal 1985.

The trust was chartered by Congress in 1949 and has a staff of 250 in its office here, its six regional offices and 16 historic properties. The organization has a budget of approximately $17 million a year.