Both underfeeding and intestinal parasites can cause a dog to be underweight. As long as the parasites have been taken care of and he is on the appropriate amount of food, then he should start gaining some weight. Being that he is only 5 months old....be sure to feed him PUPPY food (and not adult dog food) to ensure he is getting enough nutrients. Until he "catches up" on his weight, you may want to feed him an extra 1/2 to one full cup of food at each feeding. Here's hoping the little guy beefs up to his potential!