This is a really difficult topic to approach, and I think the only reliable way to identify flavours is through years and years of practice using those flavours in your cooking.
To start with, I think the easiest thing to do would be to understand the different types of flavours. Those are:
Sweet
Everybody knows this one. Sweet is the taste of sugar, candy, and so on.
Sour
Sour is the taste of acidity. Citrus fruits like lemons/limes, vinegar, pickles, and so on.
Salty
This is the taste of, well, salt. Needs no further explanation, I hope.
Bitter
Bitterness is what makes you want to grimace - but many people do acquire a taste for it. The best examples of bitter are probably coffee and beer. Leafy greens and horseradish are other good examples.
Savoury or Umami
This is the taste of "hearty" foods - meats and cheese especially. Specifically, it's the taste of protein. Glutamates (i.e. MSG) also provide this flavour.
It's actually a lot more involved than this - our taste receptors can detect many more subtle flavors, but those are the easiest to tell apart. The most notable "quasi-flavour" is probably Hot or Piquant (not to be confused with pungency, which is a more general term for anything "strong" tasting such as horseradish or garlic); this type of heat is due to capsaicin, which is found especially in chili peppers, and I call it a quasi-flavour because it doesn't actually work on taste receptors, it works on pain receptors, and it's addictive due to the subsequent release of endorphins.
Anyway, all that aside, the place to start would be to get used to the five basic flavours above. Eat some foods that are chiefly one flavour - a caramel, a lime, a few flakes of horseradish, a hunk of meat, or... a dash of salt, I guess. Get used to what they taste like.
Then you should be able to start recognizing combinations - for example, a cured sausage will be salty and savoury. Lemonade is sweet and sour. If you're able to start identifying the flavour types then you can start trying to narrow down the actual ingredients and ask yourself, "What could be adding this [bitter] flavour?"
Most full entrées will try to establish a balance of all of these flavours with all of these flavour elements. For example, a Chinese stir-fry sauce will include sweet (sugar or honey), sour (rice vinegar), salty (soy), and umami (sesame oil), and used on vegetables which are primarily bitter (i.e. broccoli). Whenever you're eating a food that's really great, expect it to have something contributing to all the basic flavours and try to think about what elements could be used to create them. Even if you only manage to figure out 4 out of 5, chances are you can substitute something else for the 5th and manage a similar taste.
Of course, it's worth repeating that this isn't just going to come magically to you. You need to pay attention to what you're cooking; only when you've constructed hundreds if not thousands of your own concoctions will you be able to deconstruct the ones that others have made - and even then, it's kind of tricky if the recipe is complicated, because lots of preparation steps will change the flavour, like browning (Maillard reaction, adds sweetness) or roasting (tends to add savouriness).
As far as spices go, they're pretty much all in the same flavour category (which I'd really just call "spicy") although they may also lend varying amounts of umami or pungency to the final dish. The only way you're ever going to be able to identify spices is to start experimenting with them - lots of them - and learn what they taste like separately and together. I would say that this takes years for most cooks, and sadly, I don't think there are any shortcuts.
Well, that's it for my intro. Hope that helps!
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.
Best Answer
Yes, all dishes should have flavour combinations, unless the dish consists of one single ingredient with no seasoning added, no oil added, it can't help but have them... even then a tomato for example has different flavour in the skin than it has in the pulp, than it has in the seeds, the inner leaves of a brussels sprouts will have less bitterness and more sweetness than its darker outer leaves... flavour combinations are almost impossible to avoid.
So to balance flavours you do have to understand them. Not everyone might agree with the combinations you choose to create and not everyone enjoys the same taste combinations, but even so, to reliably create the blend you do like, you need to understand how it is composed.
There are any number of resources online which will break flavours down to a few key groups, though not everyone describes it the same way. Essentially you need to understand what is meant by basic terms such as sweet, bitter, sour, umami and salt. To those five you can also add 'spiciness/heat' which is often considered to be more sensation than flavour.
You should read up on what it already accepted knowledge about the effects these flavours have on each other, how salt changes perception of bitterness, how sweetness can counteract excess salt but leave the umami clear. Read up what chefs have to say about these interactions and test them out, see if you detect the same effects they do.
Spend time tasting your ingredients and training your palate (I was so busy thinking of flavours as a palette from which one can choose the equivalent of colours to paint a dish as you might paint a picture that I originally spelled 'palate' as 'palette') so that you can analyse a dish and detect what makes the difference between a combination you like and one you don't. Understand your ingredients, both fresh and storecupboard ones well enough to know quickly what will make that difference.