Alan F. Grip, press secretary to D.C. Mayor Marion Barry and director of the city's office of communications, yesterday announced that he will leave the government as soon as he finds a private sector job.

Grip, 45, a chain-smoking sometimes hard-nosed press spokesman, said he was leaving the government because of the stress involved in constantly being on the defensive at the frontline of Barry's battles with the press. Grip is Barry's third press secretary to leave the administration in two years.

"I was not prepared for the intensity of this job," said Grip, who has spent most of his 10 months as mayoral press spokesman trying to counter negative publicity about Barry. "It's a drain on me. It gets to you after a while, because you wind up getting the feeling that you're always being reactive."

Grip, the D.C. government's communications director since January 1979, was named press secretary last June after Barry, enraged over a string of negative news reports, fired his acting press spokesman, Kwame Holman, and closed down the press office inside his executive office suite. Grip was brought in, Barry advisers said at the time, because of his reputation as a no-nonsense teamplayer who could play hardball with the city hall press corps.

As press secretary, Grip kept the job of director of city communications, a dual responsibility he now says is "too big a job for one person." Grip was the main advocate last year for consolidating the office of communications with the office of mayoral press secretary to keep the administration from speaking with two voices.

Grip said repeatedly yesterday that his resignation did not come because of any differences with Barry, who has lost several key administration department heads since the start of his term. "I have enjoyed the best relationship with Marion Barry that I've ever enjoyed with any boss," Grip said.

Grip also said that he was not resigning to work in the possible mayoral campaign of his old boss, former city council chairman Sterling Tucker, for whom Grip worked as press spokesman for 3 1/2 years.

It was during that period that Grip was involved in what may have been the most stressful experience of his government service -- he spent three days as one of 11 hostages held in the District Building during the 1977 Hanafi takeover there.

Grip said yesterday that he made the decision to resign after conferring with his family and physician and concluding that the intensity of the job was taking its toll, causing him to become cranky and unable to enjoy life away from the office.