When do flights get cancelled due to fog?
Other answers have addressed the case of weather that's too bad for flights to operate, but another situation that can occur is congestion. 

Take a look at the Average Arrival Rate chart for San Francisco International Airport (SFO) (more details on this in this blog post by an airline dispatcher). During visual conditions with favorable winds, they can operate in normal flow and accept 54+ arrivals/hour into two parallel runways, with departures using the perpendicular runways in between arrivals. But that only works when the cloud ceilings are above 3,000-3,500ft. That procedure relies on aircraft being able to visually see and avoid each other when flying in close proximity. 

If there's fog (or low stratus clouds that don't touch the ground, as is typical), that can't happen; you can't send jets blindly into a cloud 750 feet apart from each other. If the clouds are high enough (per the chart, a minimum ceiling of 1,600ft and 4mi visibility), they can use a special SOIA procedure (Simultaneous Offset  Instrument  Approach)—essentially a guided, monitored way to direct jets into a cloud 2,000 feet apart—and accept around 36 arrivals/hour. And if the weather is too poor for that, the average arrival rate can drop to 25 arrivals/hour or below. The extra procedures and spacing required to safely manage traffic in the weather reduces the airport's capacity.

When this happens, there's nothing that stops any specific commercial flight from using the airport—they all have the necessary technology to land in most cloudy conditions—, but the airport's capacity is now too low to accommodate everyone. The FAA will impose a ground delay program to meter traffic into the airport until conditions improve (otherwise you end up with too many flights circling and diverting to other airports, causing many other problems), and the result is flight delays and cancellations.