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:
Everybody knows this one. Sweet is the taste of sugar, candy, and so on.
Sour is the taste of acidity. Citrus fruits like lemons/limes, vinegar, pickles, and so on.
This is the taste of, well, salt. Needs no further explanation, I hope.
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!