Dear Annie: I have a weird problem that I hope you can help me with. A couple of weeks ago, my team was in a big meeting with another team, our boss, his boss, and a very senior person both managers report to. At one point, my boss was presenting the results of a research project I had worked on, and he got a couple of key figures wrong. The numbers came from an earlier version of the report that we had since revised, so I spoke up and corrected him.

I really like and respect my boss, and the last thing I intended was to embarrass him or make him look bad. I just spoke without thinking. But now he’s freezing me out and won’t even look at me. I would like to crawl under my desk and stay there, possibly forever. Is it too late to apologize? What would you say to him if you were me? —Foot Stuck in Mouth

Dear F.S.M.: Eek. It’s certainly not too late to say you’re sorry. In fact, at this point, says Lauren M. Bloom, author of Art of the Apology: How, When, and Why to Give and Accept Apologies, “Since your boss is obviously still upset with you, not apologizing is not an option.”

But be careful how you go about it. “Apologizing at the office is not the same as in real life,” Bloom says. Depending on the circumstances, “there’s office politics to think about and, in certain situations, admitting fault can get you fired.” An attorney by training, she adds that “as a rule, in any instance where you’ve made a mistake and there is even the possibility of a lawsuit over it, speak with someone in the legal department before you admit any wrongdoing.”

While researching her book, Bloom came across people who made matters worse by giving “I’m sorry” gifts inappropriate for the workplace, like one well-meaning boss who gave his assistant a bouquet of flowers. The admin “saw that as both sexist and too personal a gesture,” Bloom observes. “The wrong kind of apology can be more offensive than the original mistake.”

So, what should you say to your frosty boss? By Bloom’s lights, every effective mea culpa has six essential features. The first one is sincerity, which your question suggests you’ve got covered. Most people can spot a phony apology from a mile away, so “you have to genuinely regret what you did, and say it unequivocally,” says Bloom. “Start with ‘I am sorry.’”

Second, briefly explain precisely what you believe you did wrong, in this case correcting the boss in the presence of higher-ups. Acknowledge that you embarrassed him by speaking up and you feel rotten about it and, in the next breath, move on to Step Three: Suggest a solution for the next time this situation comes along (if it ever does), and propose a way to make amends.

“It probably would have been better to discreetly hand him a note under the table so he could correct his own mistake,” Bloom says. “You could mention that as a solution for next time.”

Making amends may be tougher and require that you swallow a few bites of humble pie. You might, for example, ask your boss whether it would help if you met with the senior manager who was at the meeting to explain the mix-up with the numbers, so “your boss doesn’t seem so clueless to his boss,” says Bloom. “Be open to any other idea he might have for repairing the damage.”

The fourth step: If your boss wants to vent, just listen. No matter what he says or how he says it, don’t interrupt or try to defend your actions. Giving the other party a chance to tell you how badly you screwed up, and how angry (or hurt, or disappointed) they are “is often the hardest part” of any apology, “but the person you’ve wronged won’t feel they’ve been heard unless you do it,” Bloom says.

Then, take a deep breath and, since this is someone who could probably fire or demote you if he wanted to, move on to Step Five: “Thank him for giving you another chance.”

The sixth and last step is pretty simple: Don’t ever do the same thing again. Says Bloom, “The people who end up with pink slips are those who don’t learn from their mistakes.”

You don’t say whether you normally have a chummy rapport with your boss but if so, a word of caution. “In lots of organizations, the hierarchy is invisible day to day, so everyone seems to be more or less equal,” says Bloom. “But even in a very collegial culture, where coworkers are friendly and casual, never apologize too casually to someone who outranks you. As soon as you’re in the wrong, the hierarchy snaps back into place. Respect it.”

Likewise, she adds, “Never make a joke as part of an apology. Humor is great for relieving tension, but it makes it hard for people to tell how sincere you really are.”

And, hey, try not to beat yourself up. Nobody’s perfect, and “everybody has an apology story, if they’re willing to tell it,” Bloom notes—including the occasional CEO. Once you’ve expressed your regret, put it behind you and move on. With any luck, your boss will, too. Eventually.

Talkback: Have you ever had to apologize to a boss or coworker, or vice versa? How did it turn out? Leave a comment below.

Have a career question for Anne Fisher? Email askannie@fortune.com.