When should I retire if mentally sharp but out of shape?

Never! You should never stop being active. Whether you are 2 or 102. Being out of shape is only temporary unless you allow it to be permanent. If you want to retire work, i couldn't help on that front!
You'll know. The idea of retirement came precisely because people get to a point where physically they can no longer keep on doing what they normally do. You're the best judge of your circumstances.