It varies greatly depending on the local jurisdiction but the two most common factors for if you need a health permit are - Are you charging for the food? or Is the size of the portion over a specific size (commonly 2oz).
I have a line of BBQ rubs and sauces. In my area, if I got to a retailer and hand out free samples of product (for example BBQ sauce on pulled pork) then there is no health permit required. However if I sell BBQ sandwiches then a health department permit (and the associated inspections) are required.
In some areas I would be able to sell samples without a permit as long as they were 2oz or less. That is how many chili or "people's choice" type competitions work.