"I goofed," an apologetic President Reagan said yesterday as he described how he offhandedly revealed during a visit to St. Louis Thursday night the closely held secret that his chief economic adviser had submitted his resignation.

When Murray L. Weidenbaum, chairman of the Council of Economic Advisers, informed Reagan earlier this month of his intention to return to teaching at Washington University in St. Louis in September, Weidenbaum asked that the news be withheld until he left for vacation this weekend.

For seven days it was. Then Reagan volunteered the information while bantering with anchorman Julius Hunter of St. Louis' KMOX-TV immediately after the two taped an interview. Hunter mentioned to Reagan that he had taught at Washington University with White House political strategist Edward Rollins.

Discussing his disclosure aboard Air Force One from St. Louis, Reagan said Hunter's mention of the university reminded him that Weidenbaum had taught there. According to a transcript of a scratchy CBS tape of the conversation, Reagan said, "We're sending someone back to you. Well, we're not sending him, he's going--our economic adviser."

Surprised, Hunter asked: "Murray Weidenbaum, is he leaving?"

Reagan: "He's going to come back to the campus."

Hunter then dropped the matter, afraid to press hard because Reagan might back off. For about two hours the news was not broadcast because, reporters for KMOX and CBS, which owns the St. Louis station, tried to reach White House aides and Weidenbaum intimates to confirm what Reagan had said.

A CBS source said the network sought further corroboration because the timing of Weidenbaum's departure appeared vague from Reagan's words and because "I'm never sure Reagan knows what he's talking about."

Karna Small, White House liaison with the non-Washington press corps, responded to initial KMOX inquiries by denying that Weidenbaum would be leaving soon. Yesterday, she said she had not known about the resignation even after Reagan mentioned it.

After Small's initial denial, White House aides asked the station to withhold the news, promising KMOX-TV an exclusive before releasing a formal announcement.

But, White House deputy press secretary Larry Speakes admitted yesterday, "It became apparent that the news wasn't going to hold . . . ." Small confirmed the resignation for KMOX, and Speakes broke the news to other reporters.