The State Department and its Foreign Service have taken a close look at their defenses against terrorism in recent months, and they are planning new steps to enhance the security of American diplomats here and abroad.

Much of the effort will be under the direction of Robert E. Lamb, who has been assistant secretary of state in charge of the Bureau of Administration since September 1983. Lamb moved down the hall on Monday to a new job -- coordinator for diplomatic security.

His 12-person office will be the forerunner of the Bureau of Diplomatic Security, creation of which was recently recommended by the Advisory Panel on Overseas Security headed by retired admiral Bobby R. Inman.

Before leaving his former job, Lamb ordered changes in the security plan for the main State Department building after an employe was fatally shot on the seventh floor June 20 by her son, who then committed suicide.

Almost immediately, the department began tighter checks on passholders entering the building. Additional steps will be taken soon. Most were in the works, Lamb said, but some were accelerated after the shootings.

Beginning this summer, department passholders will be issued new identification cards that can be read by machines at the building's entrances and at offices where access is restricted, such as the communications center and the secretary's office. In addition to screening visitors, the machines will keep a record of who comes and goes and at what times. Lamb said the plan is for the machines to be in place late this year.

The Inman panel's report also provided the blueprint for far-reaching changes in security for overseas installations. Lamb said its recommendations have been "approved in principle" by Secretary of State George P. Shultz.

The new security coordinator said his first job will be to draw up proposals for Congress to approve, especially a five-year budget plan to implement the major recommendations. Under the plans, 126 embassy or consular buildings would be rebuilt to meet the new standards. Lamb said some consulates may have to be closed if the cost of rebuilding them is too high and the consulate is not important enough.

One element of the new program is a "truth-in-recruiting" policy, to let new Foreign Service applicants understand that they are pursuing a career that may be more hazardous than they expect. Following an Inman panel recommendation, recruitment literature will try to give "a more graphic description of the hazards of political violence to our personnel abroad."

"What is being done is a response to a general recognition of the times we are living in," Lamb said. "A few years ago we could identify certain 'high-threat' countries to concentrate our efforts on, but now there are no frontiers to terrorism, and no place we can let our guard down." The result is a program that could cost as much as $3.5 billion over five years to upgrade diplomatic security.

WHICH WALKER? . . . State Department sources say the name of the likely new deputy assistant secretary for Central America will probably alarm Nicaragua. It is William Walker, currently deputy chief of mission in Bolivia.

Nicaraguan history contains an earlier William Walker, a Tennessee adventurer who invaded the country with 58 men in 1855. He took control of the Nicaraguan army and installed himself as president, ruling for two years until he was ousted. He was executed in Honduras in 1860.

Today's William G. Walker is a 50-year-old New Jersey native and career Foreign Service officer who has served in Peru, Japan, Brazil, El Salvador and Honduras. He received the department's coveted Christian Herter award last month for outstanding service in Bolivia.

He is expected to be nominated shortly to replace L. Craig Johnstone, who has been named ambassador to Algeria.