I'm off to the gym. vs. I'm leaving for the gym
Solution 1:
There are virtually no two things that mean exactly the same thing. There are always at least shades of different meaning and usage.
Let's say you're driving to the gym. Can you say either a. or b.?
If you are currently in the car en route to the gym, you are still off to the gym, but you already left, so you are not leaving for the gym.
How about when you've just arrived at the parking lot? Can you still say either?
The parking lot of the gym? At that point, it seems like you're no longer leaving nor off -- you're at.
With no object or adverb, "leaving" can be abrupt. Though "I'm leaving for the gym" is not abrupt and "I'm leaving soon" is not abrupt, simply saying "I'm leaving" can at times be abrupt compared to "I'm off," which has a certain whimsy to it. (There are tons of expressions that mean "I'm leaving" that don't risk abruptness, like "I'm heading out" or "I have to get going, now.")
Solution 2:
“I’m off to the gym” is the sort of thing I might say casually to my husband as I leave the house.
I probably wouldn’t say “I’m leaving for the gym” in that situation. I might say “I’m leaving for the gym after breakfast” or something like that, but to say “I’m leaving for the gym” by itself, although grammatically correct, sounds rather formal.
As already noted, by the time I was in the parking lot of the gym, I would have already left, so neither phrase would make sense at that point.