The Washington Star yesterday named William F. McIlwain, editor of the Boston Herald-American, to the newly created position of deputy editor of The Star.

The 53-year-old editor and author, whose 30-year career in journalism has stretched across nine newspapers ranging from Newsday to The Toronto Stat, said yesterday he hopes to come to Washington in four or five weeks, "as soon as I have a successor here in Boston."

As number two man under Washington Star editor Murry J. Gart, McIlwain "will share responsibility for various aspects of the paper's operation with executive editor Sidney Epstein," Gart said yesterday. He would not elaborate.

Asked if he had been hired to shore up any specific part of The Star's operation, McIlwain said in a telephone interview, "Not really... I guess we really need to shore in all directions."

The Star, purchased last year by Time, Inc., lost $7.2 million in the final 11 months of 1978 and expects to incur a $16 million deficit this year, Star officials have said.

In 1975, under its previous ownership, The Star had also approached McIlwain about talking the job of executive editor, but negotiations fell through.

"I very nearly came there when Jim Bellows (Gart's predecessor as editor) was there," McIlwain said yesterday. "It just never quite came together.... I don't really know why (except that) I thought it would be a little too ambiguous, what I'd be doing."

Born in Lancaster, S.C., McIlwain began his career working variously at the Wilmington (N.C.) Star, Jacksonville (Fla.) Journal, Charlotte (N.C.) Observer, Winston-Salem (N.C.) Journal-Sentinel and Richmond (Va.) Times-Dispatch.

He worked at Newsday for 16 years, becoming its editor in 1967 and holding that position until 1970.

Thereafter, he was managing editor of The Toronto Star and later the Bergen County (N.J.) Record. He became editor of The Boston Herald-American in 1977.

McIlwain is the author of several books including "A Farewell to Alcohol," an account of his recovery from alcholism.