This is going to be kind of a rambly answer, partially copypasta from something I've written elsewhere:
Someone else said: An example is a sandwich that is made with roast beef, boursin cheese and caramelized onions.
Well.. that’s a fairly classic combination.
Here’s why, roughly.
Cheese contains a lot of the fifth flavour sense, umami. This sense is, roughly, ‘savoury’; that is, those things you eat that have a great deal of satisfaction, essentially. Tomatoes, cheeses, anything fermented–these are high in umami. One of the things that umami does is to heighten and enhance ‘meaty’ flavours in your food. So pairing cheese with beef becomes more than additive, it is multiplicative; the cheese enhances the flavour of the beef.
Likewise, caramelized onions are full of complex flavours due to transformation of the sugars within the onion. Consider the vast flavour difference between white sugar and caramel. The complex flavours arise from heating the sugars. This is, by the way, the real reason why you sear meat in a pan before roasting it in the oven. Browning the proteins in the meat is known as the Maillard reaction, and creates more complex, intensely savory flavours. Adding caramelized onions (or, classically with a roast, roasted potatoes and onions) plays off those flavours.
Moving on to ‘how the hell do they do that?’
Tasty food (ignoring texture) is built on two things: complement and contrast, similar to basic understanding of art.
Let’s start with the example given of duck and blueberries. These are flavours that contrast; the fatty meaty richness of the duck with the tart-sweet astringency of blueberries. Duck with fruit is a classic pairing from the mists of time; the acid of the fruit cuts through the unctuous mouthfeel of the fat while the sweetness offers a counterpoint to the savoury flavours found in duck meat, enhancing the flavour by contrast. There are, of course, infinite combinations of this. Consider very everyday examples: beer nuts (salty peanuts with a sweet coating), ice cream sundaes (cold sweet solid ice cream with hot slightly bitter liquid chocolate/fudge sauce), or the MetaFilter favourite of peanut butter and pickle sandwiches (soft creamy salty-sweet peanut butter with crunchy sour pickles). In each case, the contrasts enhance each other; in the duck example the sweetness of the blueberries makes the duck seem more savoury while the duck makes the blueberries seem sweeter.
Then there are flavours that complement each other. The easiest to understand is the combination of coffee and chocolate. Each brings dark, roasted, complex flavours to the table which marry incredibly well with each other because they match. And then there is (unless using wholly unsweetened chocolate) the contrast between bitter coffee and sweet chocolate, each flavour playing off the other.
So when you are looking at flavour combinations, you want to look at three things:
1) Flavours which contrast each other: sour/sweet, salty/sweet, fatty/acidic. The list goes on.
2) Flavours which complement each other (more below).
3) And the gestalt; flavours which both contrast and complement, as with the coffee/chocolate example.
Finding contrasting flavours is relatively simple. But note that you are not looking for diametric opposites, necessarily; the bitterness of asparagus is unlikely to pair nicely with the sweetness of caramel, for example. Which is why you really aim for the gestalt.
Finding complementary flavours, I think, is more difficult. In my view, what you are looking for is a flavour note that is common amongst two or more ingredients, while ensuring that none of the ingredients has wildly clashing notes.
Consider these three ingredients:
Turkey
Cranberries
Chocolate
The first two go together by way of contrast. Ditto the last two. And turkey with (unsweetened) chocolate would work very well–think about a mole sauce. But all three would (probably) not work well together without a lot of very careful finessing. There’s a theory about any three ingredients, but I can't remember the link.
end copypasta
To bring it to more quantifiable terms, McGee explores a lot about flavour pairing in On Food and Cooking, paying specific attention to volatile compounds which work well together. In many cases, it seems, foods which share compounds go well together; this is how Blumenthal put cauliflower and cocoa together, as they share a dominant compound (I cannot remember what it is). So there's that, when we're talking about aromas. My copy of McGee is currently with a friend, otherwise I'd cite you chapter and verse.
In terms of the five basic (primary) flavours you were talking about, I think it comes down to balance. Sweet is a flavour we are hardwired to seek out, as it promises high caloric input, a useful feature thousands of years ago. And the flavour of 'sweet' seems to balance out any other primary flavour; too sour? balance with sugar. Too salty? add sugar. Too bitter? add sugar. Umami itself seems to provide balance in many cases, and pairs especially well with salt (unsurprising given that MSG is a salt itself).
I'd really like to map flavours based on the primary/secondary/tertiary classification you've mentioned, and then look at popular pairings based on those characteristics.
This is the same question, in essence as why any of these combinations are dissonant or unexpected:
- Marina sauce on soba noodles
- Cheese on Chinese stir fry
- Haggis jambalaya
Every cuisine is a part of a culture, and there are cultural expectations for what is normal or not normal.
A deeper question would be how and why such cultural expectations develop.
Note that this is a speculation, but an informed anthropological speculation:
Every cuisine is associated with a geographic region, where certain agricultural products are prominent. The people in the area, quite naturally, learned to cook with the resources they had available. So it would be odd for a mountainous culture like Tibetans to have seafood dishes, just as it would be odd for the inhabitants of modern day Shanghai to have Yakk milk dishes.
Over time, the culture adapts and finds flavor combinations and techniques that are applicable to its resources (stir frying in china, for minimal fuel use, for example). These traditions form the backbone of the cuisine, and are how we recognize what is or is not part of that cuisine.
This allows us to make an educated guess as to why balsamic vingegar seems odd in Mexican food.
Mexico has not historically been a land of the grape, so they do not have a wine making or vinegar making tradition. Therefore, a product like balsamic vinegar is not a part of their tradition.
Balsamic is also well identified with the part of Italy now called Modena, where it would have evolved because grapes were available, and there was a wine making industry already.
Putting the two together confounds cultural expectations.
Nonetheless, there are many chef's who enjoy and practice combining foods and technique across cultural and cuisine boundaries, and thus we have the modern practice of fusion cuisine.
Best Answer
I expect that you have already considered the most probable answer. For some spices, the aromatic compounds are released by some heat, but are not destroyed. Thus their effect is heightened. For other compounds, even a small amount of heat will destroy them and thus reduce their effect - see Mischa's comment.
I believe that the difference essentially lies in at what temperature a flavoursome compound starts to degrade.