Is it possible to detect a player consuming food items?

You can make scoreboard objectives of type minecraft.used:minecraft.<food item name>, for example

/scoreboard objectives add eatBread minecraft.used:minecraft.bread

The only food item this doesn't work for is cake, since cake is not eaten in item form. To detect eating cake, use the objective type minecraft.custom:minecraft.eat_slice_cake instead.

As a minor note, it is not necessary, or even a good idea, to determine whether players are allergic using teams. Players can only be on one team at a time; what if you want a player to be allergic to both wheat and fish? Instead, I recommend that you use tags, like so:

/tag @r[limit=X] add wheatAllergy

Then, to detect that a specific player has eaten a food they are allergic to, you can use

effect give @a[tag=wheatAllergy,scores={eatBread=1..}] minecraft:poison 10
scoreboard players reset @a[scores={eatBread=1..}] eatBread

effect give @a[tag=wheatAllergy,scores={eatCake=1..}] minecraft:poison 10
scoreboard players reset @a[scores={eatCake=1..}] eatCake

effect give @a[tag=wheatAllergy,scores={eatCookie=1..}] minecraft:poison 10
scoreboard players reset @a[scores={eatCookie=1..}] eatCookie

# And so on...

There are statistics for using items (consuming a food item counts as using it) that you can use to create scoreboard objectives.

For example:

/scoreboard objectives add bread stat.useItem.minecraft.bread

will detect when players have eaten bread.

You can then use this for what you want to do:

/effect @a[team=wheatAllergy,score_bread_min=1] minecraft:poison
/scoreboard players reset @a[score_bread_min=1] bread

Alternatively you can also use a combination of advancements and functions, but they're more work to set up. If you're interested in this method just let me know.