Kubasik, 51, who was the defense contractor's president and chief operating officer, had been slated to become CEO in January, replacing Bob Stevens.
In a statement, Kubasik expressed remorse.
"I remain confident in the future of the company. I regret that my conduct in this matter did not meet the standards to which I have always held myself," Kubasik said.
During a special session on Friday, the company's board named Hewson, 58, to replace Kubasik as president and chief operating officer immediately.
She was also elected to succeed Stevens as CEO effective January 1, 2013.
In 2012, Hewson was ranked No. 19 on the annual Fortune magazine list of the most powerful women in U.S. business. Her new role at the top of the Pentagon's largest defense contractor should push her much higher.
Stevens said he was "deeply disappointed and genuinely saddened" by what he called a "very unfortunate moment." But the situation should not undermine its standing with the Pentagon, other customers or its shareholders, he said.
Lockheed has long prided itself on rigorous ethics rules, even as its rival Boeing Co was plagued with problems that led to the resignation of two chief executives and prison time for two former senior executives.
"I don't believe the company's in crisis," Stevens told reporters, citing the Lockheed's strong team of leaders and continued growth prospects. "We believe that strategically and operationally and financially we will not miss a beat."
He stressed that Kubasik's actions "did not affect the company's operational or financial performance."
Stevens said he would become executive chairman and would work closely with Hewson on the leadership transition throughout the coming year.
He said the Bethesda, Maryland, based company had no immediate plans to name a chief operating officer to serve alongside Hewson, whom he described as "an exceptional leader with impeccable credentials."
Hewson said the company had proven resilient during previous management changes and that it would remain focused on meeting its commitments, cutting costs and drumming up new business.
"We will move forward beyond this temporary distraction together," Hewson, told reporters.
Stevens said Lockheed hired an independent investigator in October to look into the matter after an employee came forward with concerns about Kubasik's relationship with another staff member.
The investigation ended on Friday when the board asked for, and received, Kubasik's resignation. He admitted to having "a close personal relationship with a subordinate employee" that violated the company's code of ethics and business conduct.
Stevens said the company's swift actions showed its "unflinching commitment to ethics and integrity in everything that we do."
He said the woman involved in the relationship with Kubasik had also left Lockheed.
The news about Kubasik's improper relationship emerged hours after CIA Director David Petraeus resigned after admitting to an extramarital affair.
Lockheed disclosed in a filing with the U.S. Securities and Exchange Commission that it would pay Kubasik $3.5 million in severance, but he would not receive a separate bonus for 2012.
Hewson has been with Lockheed Martin since 1983. She was named president and chief operating officer-elect in April.
Lockheed shares rose to $90.04 after hours after closing at $89.98 at the New York Stock Exchange on Friday.
(Reporting By Andrea Shalal-Esa; Editing by Ros Krasny, Leslie Adler and Marguerita Choy)
By Andrea Shalal-Esa