This answer might vary between types of chillies, but I'm curious to know when they're hottest.
McGee writes: "Capsaicin appears to accumulate in the fruit concurrently with the pigment during ripening". (On Food and Cooking, p.212)
So yes, chilis get hotter as they ripen (that is, as they turn from green to red). Many chili varieties are picked and sold in stores while still unripe and green (e.g. jalapeño, serrano, poblano), but you will occasionally see ripe, red ones in stores.
All of the dried chilis I've seen in stores have been completely ripened before drying (e.g. chipotles, which are smoked, dried red jalapeños and anchos, which are dried, red poblano peppers).
I've personally observed this effect with padron peppers, which are usually picked green and mild, but can ripen to red, hot peppers if left on the plant.
I know this is an old post, but had to reply. I grew jalapenos this year, and the heat difference between green and fully-ripened red is astounding. The green jalapenos had a very, well, green flavor like that of a green bell pepper, but with a mild heat.
After reading a lot of posts around the web, that almost all seem to say that peppers get "smoother" as they ripen, I interpreted that as meaning that the heat wouldn't increase. My interpretation was faulty! The red, ripened pepper was many, many times hotter than the green. I wasn't expecting that burst of flavor when I popped a slice of pepper in my mouth to experience the "smoothness" of the ripe pepper!
I can't tell you the science behind it, but I can verify that, at least in my garden and with my jalapenos, the ripe peppers are far hotter than the green.
Most chiles become more picante as they ripen. But they also become much sweeter. Jalapenos are a good example. Red jalapenos are much more delicious than green ones. Most of the 'heat' is in the seeds and the tissue connecting the seeds to the capsule. You can pare those parts out with a small knife. I eat most of my ripe jalapenos right in the garden, pocket knife in hand!
I have traveled the world seeking hot peppers here is what serious farmers have helped me to understand. Mother nature uses animals to spread seeds. If you notice most peppers have two strategies to make sure animals don't eat the fruits before the seeds are mature. First one when the pods are immature the peppers are well camouflaged (blends in with the srems or leaves) and as they start getting larger and more noticable they get very hot so as to deter animals from eating them until the seeds are ready to be distributed in the animals "poop". Just prior to maturity the placenta is larger and the hottest. Very quickly now the pods change color and become noticable and sweeter to attract the distributors but the placenta membranes start shrinking and the "hot" concentrates briefly. At this moment when they are changing color is the best if you want the heat. A couple of days can make a huge difference in heat and either bitterness or "sweetness", just understand this is not a "sweetness" as in sugar or honey but a reduction in bitterness.
They definitely get rotter as they ripen. The green jalapenos in the supermarket are very mild. As they get a touch of red surrounded by yellow they are hotter. I got some, marketed as red jalapenos and they were not hot. In fact they had very little flavour. They must have been purposely hybrid to be mild. I've grown round red ones from the previous years seed for a long time. This year they were on the plant long after they were red and they weren't nearly as hot. It seems to me the sweet spot for heat is as, or just after they change colour. On the same porch my birds eye and cayenne, were quite hot this year, so it didn't seem to be just the season.
Regardless of color, the amount of time on the vine or bush is what matters. Many items start losing flavor or appeal when left on too long. A pepper becomes hotter the longer it is left on. Peppers in the stores are just at the beginning of being ripe. Farmers harvest as soon as they become ripe to make way for the next harvest and to get to the store before bugs and other pests can get to them. We have been growing a wide variety of peppers for years now. At the end of the season, if we have not kept up with picking, we end up wearing gloves. We have had jalapenos that can burn our skin from the touch because the capsaicin starts leeching out the stem.