A very difficult part of food allergies or autism, if you are sticking to a diet, is explaining to the child that they can't eat what someone, or everyone, else is eating. As every child is different, I'm sure ways of explaining and what works will be different as well. I'll share what has worked for us.
For foods that he has an obvious reaction to such as dairy, which results in stomach pains and vomiting, it's not too difficult. "Sorry sweetie, that makes you sick; but this doesn't you may have this."
Foods that may not have such an obvious reaction can be a bit more difficult. For us, gluten is the most difficult to explain. It doesn't make him physically sick, in fact there are no signs of it bothering him, except that after weeks of eating it, he struggles with his speech and his communication abilities greatly diminish. When it is removed from his diet, 3 weeks later he is speaking great again. Because he wants to eat some of the other things that have an obvious reaction, I have explained that we are working to help his body heal, so someday he can eat those things. When he wants to eat something with gluten (or junk food that he isn't allergic to) in it, instead of explaining that it will make him sick - because one of these days he'll try it and happily tell me that, "It doesn't make me sick!" when he doesn't see any affect from eating it - I explain that, "It isn't good for your body and won't help your body heal." He often replies, "But, when my body is healed, I'll be able to have it?" Depending on what the item is, makes a difference in my answer. If it's healthy, I'll say, " Yes, when your body has healed, you'll be able to eat it." If it's not healthy, I'll say, "Yes, someday you may be able to eat it, but it still won't be good for you."
It has been my experience that helping him understand that certain foods make him sick or prevent his body from healing has really helped with him wanting foods he can't have and accepting an suitable alternative. I also always keep something he can eat in my purse - a Larabar or dehydrated fruit strip. Even if he can't have what everyone else is having, at least he can have something that he likes very much.