There are some parts of your post that were very similar with what we saw with our daughter. As a baby, she also spit up a lot and had weight gain issues; but she also had sinus infection/congestion issues. Her pediatrician told me that we needed to significantly increase the dairy fat in her diet--"Give her ice cream, ice cream, ice cream; don't care about the sugar!". So for the next 3 months, she ate so much high fat dairy foods--I even made her mac & cheese out of cream frais and whole milk (omg, it tasted so good! My husband joked she would either gain weight or have a heart attack!). I thought she'd gain weight for sure... Nope!
We then did a skin prick allergy test which confirmed she is allergic to cows milk proteins--which was why she never gained any weight! Basically, the cows milk irritated her intestines so much that it interfered with the absorption of all other nutrients. (We previously had done a blood test to look for milk allergies, but it came back inconclusive.) Once we cut cows milk and cows milk diary completely from her diet (and I mean totally out of all food--had to read ingredient labels), she started gaining weight (and her congestion/sinus issues ended). She's not a large girl anyway, but at 4 yrs, she's in the 45% in height and 30% in weight. Her pedi has not been concerned with her weight since she was 2 1/2.
I chose not to do the soy route. Instead, she eats goat milk and goat dairy (yogurt, butter, cheese). If you haven't considered cutting out cows milk, perhaps you could do it for 3 months and see if he gains weight-?
Your son might have a cows milk protein allergy or he might be lactose intolerant. Being allergic to cows milk protein is not the same as being lactose intolerant. Those are 2 different allergies. A diet for someone with lactose intolerance might still contain cows milk protein... So, you can't feed one type of food for the other allergy. You really need to know which allergy you're dealing with... You can ask your pedi about how you can get a skin prick test for a food allergy. We were refered to a pediatric allergist.
Good luck!