Elon Musk needs to be punished until he gets a handle on his Twitter habit, says one former federal securities regulator.

The Tesla CEO lashed out at the Securities and Exchange Commission on Tuesday, a day after the agency asked a judge to hold him in contempt for some tweets the SEC says were inaccurate and violated the terms of an agreement Tesla and Musk made last year to settle securities fraud charges.

"Something is broken with SEC oversight," Musk tweeted.

But former SEC Chairman Harvey Pitt said the agency is acting responsibly.

"We've got a CEO who, I guess for want of a better word, is irrepressible," Pitt said. "He needs to have a certain amount of repression of his instinctive drive to go to Twitter. So I think that holding him in contempt, fining him, and leaving him with strict instructions that if this continues, the punishment will be worse would be in order. At least that's what I would do under the circumstances."

Musk has been sparring with the SEC after he announced on Twitter last summer that he secured the funding needed to take Tesla private at $420 a share, only to later walk back those statements. Investors thought Tesla's troubles with the agency were over when the parties reached a settlement late last year.

The agreement with the SEC prohibits Musk from using Twitter to make statements about the company's operations or financials without company review and approval.

But on Feb. 19, Musk said Tesla will produce about 500,000 vehicles in 2019, only to correct the forecast to 400,000 several hours later.

A federal judge on Tuesday gave Tesla and Musk until March 11 to explain why she shouldn't hold Musk in contempt for his latest series of tweets.

Correction: This story was revised to correct the price Musk had tweeted about taking Tesla private. It was $420 per share.