Clichès aside, honesty really is the best policy if you discover an error in your own published work. It can be in your own best interest to self-report inadvertent errors to your publisher. Some errors can be handled with corrections rather than retractions. In the event that a work needs a complete retraction, self-reporting helps to indicate that an error was innocent, rather than a deliberate attempt at deception.
Remember, failing to correct a known error can negatively impact all the other researchers who follow you, those that reference your research in their own work.