Or is it the guest’s responsibility to share? What do you do if you are served something you can’t eat?
Generally speaking, it is the host's responsibility to ask his or her guests if they have a dietary restriction or preference. If it’s a formal affair, asking about dietary restrictions can be on the invitation. If it’s casual, the host can ask when extending the invitation. It’s usually a good practice to inquire about dietary restriction because things can change. For example, several of my friends recently started eating a Vegan diet. I might not have known that if I hadn’t asked if anything had changed when I called to invite them to have dinner with us at our home.
However, if you have dietary restrictions, and were not asked about it when you were invited out, then it becomes your responsibility to make your host aware of your restrictions or preferences. Maybe the host was too busy, or simply forgot to ask, but you should help them out by telling them your restrictions. This is the polite thing to do, and it allows you and the host to avoid an awkward situation later. If you require something that is difficult to make or find, you may offer to bring it.
Remember, you do not need to go into any long explanation of why you have restrictions, merely alert your host of what you can or cannot eat. Your host wants all guests to have a wonderful time and enjoy the meal, as do you.