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
I have noticed that basil changes its taste as it ages, but not as to get bitter. On the other side, I like a bitter taste, so I often overlook (overtaste?) bitter notes to which other people show a strong reaction. Try getting some fresh basil and comparing the taste/aroma of the fresh and the old one, maybe it is really just the aging difference you perceive as unpleasant. I regularly use the stems when I have fresh basil.
Generally speaking, you cannot deceive your brain to not perceive bitterness (unlike sourness, which is counteracted by sweetness - the pH value of Coca Cola (2.6) is lower than that of tomato juice (4.1), but the soft drink is perceived as sweet, not sour). But if you mix it with another basic taste, the combination might feel much better than the pure bitter taste. The other strategy would be to just dilute with something bland, in order to reduce the bitterness intensity. Most adults actually like some bitterness if it is not too intense. The third option would be to use something with a very strong flavour to mask everything, e.g. add lots of raw onions and/or garlic, or just make it so hot you don't actually pick up much of a taste. I am not a fan of this solution, but your mileage may vary.
As for a taste combination, which taste should you pick? Strangely, people tend to think that a sweet taste is well suited to somehow "mask" bitterness, which I cannot confirm. For me, both tastes, bitter and sweet, stay there, and one doesn't mask the other, they just create a specifically unharmonious combination. In my experience, bitter + sour is a much better combination (think grapefruit, cranberries, or tonic water) which can even allow for a small amount of sweetness, without making it clash. But it is also good to make a combination of bitter + salty taste. While umami can be combined with bitter too, it doesn't diminish the unpleasant sensation of the too bitter.
As for your specific problem, I often eat basil dips, only I tend to base them on feta cheese. I sometimes add sour cream or other dairy products, but usually less sour cream than cheese. I think that it will be a good solution for your problem, as it will both complement the bitterness with a strong salty taste, and dilute the bitterness concentration as you will be using lots of it. I also almost always add lemon juice (should help for the bitterness too) and a dash of olive oil (which shouldn't affect the taste, only the aroma). Another ingredient which does well in a basil dip are green or blonde olives, if their salt level is not too high.
For a basil dip, I usually throw everything in a bowl and smooth it with the immersion blender. If you aren't sure that you'll like the taste, try tasting a spoon of your current dip with a small piece of feta and/or an olive before committing more ingredients to something you'll ultimately throw out.