In addition to blood work to rule out a thyroid problem, you might inquire about celiac disease/gluten intolerance. It is my understanding that this can be difficult to diagnose, but can sometimes explain failure to gain weight or unexpected weight loss. I had a student who was diagnosed the year she was in my first grade class - she was so tiny! While naturally a smaller kid to begin with, the celiac was keeping her from growing.
Good luck - it sounds like you have a wonderfully active child on your hands! I also agree with the commenter whose doctor said better to be underweight than over!