Our last dog had this problem,until we changed the walking area.I don't think it is anything to do with food at all.Our Vet described this ailment to us as the different growing stages of the bones either side of the joint.They should grow at the same rate, but sometimes the rate differs and then the pain and limping start.I recall having this myself in Jnr School! My mother called it "growing pains!"
Anyway going back to our dog,we took him off road walking completely and once on soft paths and grass we noticed a big change.Obviously not too far as even on grass this complaint will flare badly if walked too much.We also gave him prescribed nsaid drops for a week.We did occasionally revert to the drops but not very often.
If we took him back onto road walking,the complaint would flare up.It eventually went away after many months.Hope this helps, and try not to worry as it will go eventually.The Vet said in large breeds this can carry on for 2 years, but he also pointed out that many small breeds are also affected just the same.