Relevant Rules
Grappling consequences:
You lose your Dexterity bonus to AC (if you have one) against opponents you aren’t grappling. (You can still use it against opponents you are grappling.)
Footnote regarding pinned and helpless defenders' AC in Favorable and Unfavorable Conditions, marked against the -4/+0 modifiers for melee/ranged for each:
Treat the defender’s Dexterity as 0 (–5 modifier).
If You're Pinned by an Opponent:
While you’re pinned, you take a –4 penalty to your AC against opponents other than the one pinning you.
Example
Fiona's BAB grants her multiple attacks. In a grapple, she uses one of these to successfully pin Edgar, and the next to attempt to use his rapier against him. She succeeds on the opposed grapple check and makes an attack roll with the weapon, taking a -4 penalty.
Edgar retains his Dex bonus against Fiona, and does not suffer the -4 AC penalty he would against other opponents. Therefore,
- As Fiona is the one pinning him, his AC is unchanged (10 + Dex + mods), or
- As he is pinned, his effective Dex is 0, and a -5 Dex modifier is applied to his AC (10 – 5 + mods).
So which is it?
RAW seems ambiguous to me here, but I am inclined to think number 1 applies. The footnote above is attached to a modifier that is applied to non-pinning opponents. The intention of pinning is probably a "I'll hold him, you punch" tactic rather than locking them down one-on-one.
On the other hand, if a pin is representative of your holding a character so still that their Dex is effectively 0, then he's not moving with respect to the pinner either.
Best Answer
All attackers—not just the pinning creature—treat a pinned creature's Dexterity as 0 for determining the pinned creature's Armor Class
The Player's Handbook's glossary describes pinned as "held immobile (but not helpless) in a grapple." That immobility is represented by treating the creature's Dexterity as 0 for determining the creature's Armor Class.1
Thus, initially, the grappling creature and the grappled creature lose their Dexterity bonuses to Armor Class against attacks made by creatures not involved in their grapple (PH 156).
Then the pinned creature—who's also grappled as that effect has yet to be remedied—is treated as having a Dexterity score of 0 for determining Armor Class (PH 151), but the pinned creature is not paralyzed (as a creature with an actual Dexterity score of 0 usually is) (PH 304, 311), and the pinned creature is not helpless (PH 153).
Further, the pinned creature suffers an additional −4 penalty to Armor Class against attacks made by creatures not involved in his grapple (PH 156).2
If this seems excessive, try imagining being pinned as failing a second saving throw against an effect. Since failing the first could've killed the creature, probably either grappling is the creature's specialty, the grappling creature wants the grappled creature alive, or nobody's casting spells.
Grappling is one of the primary reasons many high-level creatures have access to some kind of freedom of movement effect (e.g. the ring of freedom of movement (DMG 232) (40,000 gp; 0 lbs.)).