Coffee foam vs. Tea foam
During roasting, carbon dioxide is generated (the beans are burning, after all) and trapped in coffee beans. According to the book Espresso Coffee, a kilogram of freshly roasted beans contains as much as 10 liters of carbon dioxide. This carbon dioxide is the main gas component of espresso foam. Over time, unused beans will release that gas into the air, or de-gas, leaving less to create the crema on your espresso.

They say that coffee is not best immediately after roasting, but needs a few days to reach its peak. I've heard that this is because of the excess carbon dioxide, and I've heard that the "flavors need to develop." I'm not sure what the truth is. I don't normally get my beans that soon after their roasting, so I can't speak personally to the differences.

I don't know much about tea, so I can't help you there...