A) Paying attention to things they say can help. For example, Gwen straight up tells you that she loves a particular dish.
B) Sometimes there are hints in the world if you pay attention to where you find that spirit and what else is around. For example, one spirit is on the same island as a chest containing the recipe for their favourite food.
C) There’s at least one quest where you find out some spirits’ favourite foods (by asking them). Other quests have you give a spirit their favourite food without outright telling you it’s their favourite.
D) General likes and dislikes usually make sense for their character, so someone who prides themself on being plain-spoken and working class might like plain food, while someone who is openly eclectic in their tastes is liable to favour more exotic fare.
E) Experimentation and trial and error will eventually stumble across all a given spirit’s food preferences.
There’s no universal rule for how best to find out a given spirit’s tastes within the game.