1. Two cabbages
"I ate some cabbage for dinner" - cabbage as a menu item is uncountable.
2. Three heads of lettuce (the whole thing)
Three pieces of lettuce (each leaf)
3. Four bunches of spinach
Four pieces of spinach
4. Eight pumpkins
5. Two heads of garlic (the entire bulb)
Two cloves of garlic (the pieces within the bulb)
Sorry it's not very systematic, but that's how English works! I think there's no better way than to remember each of these.