Uncooked and cooked ham on the bone can last up to 5 days in the refrigerator but it's usually not as fresh after 3 days although it's still safe to eat as long as it smells good and isn't too slimy.
You can keep the ham on the bone longer in the freezer so if you want to keep the ham on the bone longer than 5 days you should freeze it.
Frozen ham on the bone will keep from 6 months to a year but only 3 to 5 days in the refrigerator.