Regardless of type, all chocolate should be stored in a cool and low humidity (dry) place away from direct sunlight. It would be best to seal it in an air-tight container, because, as ElendiTheTall said, the cocoa butter in it will absorb flavors.
Dark chocolate will last for years. Milk and white chocolate will last for a much shorter time (a few months), because of their milk content.
Improperly stored chocolate will develop bloom, which shows as a white or grey streaking or spotting on the surface. The spotting or streaking is cocoa butter fat separating and is a sign that the chocolate's temper has been lost. This kind of chocolate is still suitable for any application where the chocolate will be fully melted (most baking). It can even be used as the base (non-seed) chocolate for tempering with the seeding method, but it should not be used for other candy making.
They will technically last a long time in the freezer - up to many months - but this is not the best way to store them as they lose flavor quickly (as little as 5-6 uses). Even though the beans will last, storing them in the freezer is not ideal. It affects flavor for a number of reasons. (See below)
If you haven't opened the bag, store the bag in the cupboard, away from sunlight, heat, and excess humidity.
The best way to store coffee beans after being opened is in an opaque, airtight container at room temperature (unless you have a resealable bag with a degassing valve designed for storing coffee). After being opened, the beans are considered fresh for 2-3 weeks, although if you are strict about the storage you may be able to get up to 5 out of them. (When I say fresh, I mean with minimal flavor change/loss)
Why the freezer is bad:
Freezing beans severely lowers the humidity in the bag or container. This causes the beans to become stale very quickly. In effect, you are slowly freeze drying them. Also using cold beans in a grinder can mess with grind due to the oil on the beans being in a more solid state, which in turn affects the brewing.
If you do decide to store them in the freezer, put them in an airtight container and when you go to use the beans let the container warm up to room temperature before opening. This way you do not mess with the overall humidity content of the container too much. Especially let them warm up to room temperature before grinding.
Sources:
I am a Barista in a cafe and a lover of coffee at home. I have tried both methods of coffee storage and have dealt with many customers who have tried both.
In my store we follow these regulations:
- Beans that go into an opaque container that is not totally airtight are fresh for two weeks max.
- Packaged beans with a degassing valve are fresh for six months or longer in the bag.
- Beans, once ground, cannot be used after two hours (that being said, ground coffee starts losing flavor immediately).
Obviously, the sooner you use everything the better, but we follow those guidelines.
Best Answer
My wife is obsessed with Milka, and last time we were in Germany, she threw out all my clothes in order to fill an entire suitcase with it. When we got it home, it got piled in the freezer (not the freezer-in-the-garage-which-is-seldom-opened, but the regular one where we keep ice cream and frosty beer mugs). Took us more than 4 years to finish it. The last bit was effectively identical to the first. No noticeable change in the product.
Given that quality chocolate has no water (which is the primary freezer-spoilage agent), I'd say it would keep effectively indefinitely. If you're talking about candy bars which contain other ingredients, it may vary.
Generally though, things don't go "bad" in the freezer. They can get brutally freezer burned and disgusting, but there is no safety issue, as long as the food remains frozen. I once made a pie out of a quart of blackberries I found buried in the ice in an old-style freezer chest. Estimated age was on the order of twenty years, but they'd been preserved by the encroaching frost. Pie was delicious.