It all depends on the amount of lactose remaining in the food (lactose is the sugar found in milk and other dairy products). Yogurt that contains live bacteria cultures typically can be consumed because the bacteria produce enzymes like lactase that break down much of the naturally-occurring dairy sugar. Converting lactose into lactic acid makes the yogurt much more tolerable for the sensitive stomachs of those with lactose intolerance.
This same phenomenon also makes some cheese varieties acceptable for intolerant tummies. The Lactobacillus bacteria used to produce most types of cheese remain well after it has been sold and continue to process its lactose. According to food science professor Scott Rankin of the University of Wisconsin, “in theory, most of the lactose [in cheese] is gone after three months of aging.”
(Sources: 1, 2)