Determining two heavy coins out of 27 can be done in 5 weighings. It's been several hours, so I'll skip the spoiler tags (also, i don't know how to spoiler large sections of text). I don't have a generalization, yet, but if i come up with one, I'll edit it in.
Label the coins 1-27. Take three weighings:
First: $1$-$9$ vs $10$-$18$ vs $19$-$27$
$1,2,3,10,11,12,19,20,21$ vs $4,5,6,13,14,15,22,23,24$ vs $7,8,9,16,17,18,25,26,27$
Third: $1,4,7,10,13,16,19,22,25$ vs $2,5,8,11,14,17,20,23,26$ vs $3,6,9,12,15,18,21,24,27$
If the two heavy coins are on the same pan, then the pans will balance. Otherwise the one pan with no heavy coins will rise. Since there is no combination of two coins that are on the same pan for all three weighings, for at least one of the three weighings, one of the pans must rise.
Name a weighing where one pan rose as weighing "alpha".
Alpha: Considering weighing alpha, relabel the coins on one of the heavy pans as A1 - A9, the coins on the other heavy pan as B1 - B9, and the coins on the light pan as C1 - C9. (Preserve order on the numberings). We know that one of the heavy coins is an "A" coin and one is a "B" coin and all the "C" coins are normal. This leaves us with 81 possibilities, picking one each from two sets of 9 elements.
One of the weighings performed had a pan with A1,A2,A3,B1,B2,B3,C1,C2,C3. Name that weighing "beta". The other weighing had a pan with A1,A4,A7,B1,B4,B7,C1,C4,C7. Label that weighing "gamma".
Beta: No pan rises: If no pan rose for weighing beta, then both heavy coins were on the same pan for that weighing. The combinations that satisfy this are:
For a total of 27 possibilities.
If no pan rose for weighing gamma, then the possibilities are Ax,Bx, where x is the same for both, for 9 options remaining. If the third pan rose, then there are 6 options: A1B2, A2B1, A4B5, A5B4, A7B8, or A8B7. In any case, there are 6 or 9 options, which do not overlap.
Split 3 pairs onto the first two pans and split 3 pairs onto the first and third pans. If you have 9 pairs, split the last 3 pairs onto the second and third pan. Otherwise, add 3 other coins to each of the second and third pans.
During this fourth weighing, you have definitely split the two heavy coins, so a pan will rise. That will leave you with 3 pairs for possibilities. Split one pair on first and second pans, second pair on first and third pans, third pair on second and third pans. The fifth weighing will tell you your answer.
For example, weighing gamma was flat, then weigh:
vs B4,B5,B6,B7,B8,B9. Each of the 9 pairs are split, 3 for each combination of two pans.
If the second pan rose, the remaining options are A4B4 or A5B5 or A6B6. On the fifth weighing, compare A4,A5 vs B4,A6 vs B5,B6. If the first pan rises now, the heavy coins are A6 and B6.
Beta: One pan rose. If one pan rose in weighing beta, there are 18 remaining possibilities. Consider the case where the third pan rose (the others are symmetrically solved). The remaining options are:
If no pan rose for weighing gamma, there are 6 options remaining: A1B4 or A2B5 or A3B6 or A4B1 or A5B2 or A6B3. If the third pan rose, there are 4 options remaining: A1B2 or A2B1 or A4B5 or A5B4. Similarly, there are 4 options if either of the other two pans rose.
In any case, there are either 4 or 6 options, with no overlap. Proceed as above, splitting the pairs evenly. If there are only 4 options, you can leave a pair out and complete in 4 weighings. For example, if the third pan rose on weighing gamma, then for the fourth weighing compare:
A1, A2 vs B2,A4 vs B1,B5. If no pan rises, the heavy coins are A5B4. Otherwise, the fourth weighing would indicate which coins the heavy ones are.
So, in summary, it can be done in 5 weighings, and the arrangements of coins on the first three weighings can be determined ahead of time. The relabeling steps I took simplify the number of cases and minimize the "assume without loss of generality" steps.