Hi J.,
My 13 month old son has had the exact same problem from age 7 months to about 12 months, off and on. My boyfriend (son's father) is an ER Nurse who takes care of babies all of the time, and between that and specific advice from our son's pediatrician on this exact issue, here is my advice I have learned works.
Switch the formula you are giving him to Enfamil Nutramigan which prevents colic and within 48 hours will soften his stools and make his poop alot easier to pass. It will look yellow and mushy but he will not have pain and will get his nutrients. Our son has had this since birth since I was unable to breastfeed right from the hospital and we still give it to him in addition to food.
All of the pitted fruits work on solving the painful bowel movements. Puree steamed prunes and give it to him everyday, probably twice a day in addition to whatever other food you feed him. Pureed cooked peaches also work very well. Plums and apricots also work but they are more sour once cooked so stick with prunes and peaches. After about 4 days, your son should be pooping a lot better.
In the meantime it helps if you give him a glycerin suppository when he wakes up after he has had breakfast, and then let him crawl around and get some exercise. Within 30 minutes he will be pooping out the hard poop. He will cry and be in pain until all of the hard poop is out. Just hold his knees bent up toward his chest and lay him on his back on his changing table so the poop comes out faster. My boyfriend had to manually pull the impacted poop out (remember, he's an ER nurse), and it was horrible to watch our son be in so much pain. If our son for some reason does not poop within 48 hours, we give him a glycerin suppository in his behind (or half of one) and all of the backed up poop comes out on its own within 30 minutes.
Better to keep your baby's bowel movements regular than to let him get too backed up and not poop for days, because when that happens it is going to be much more painful for him the longer he goes without pooping. As I said, the Nutramigen helps a lot and that in conjunction with cooked, pureed pitted fruits (peaches and prunes) will do the trick after about 4 days.
Good luck.