I'd say that you can't use Combat Expertise in the same round that you cast a spell with a melee touch attack (unless it's a quickened spell), but if you fail to hit your opponent the first time, you can use it in subsequent rounds.
Any argument for the use of Combat Expertise in conjunction with casting a spell with a melee touch attack can be generalised to spells with ranged touch attacks and from then on to all spells. It can also be generalised from using Combat Expertise to using the Fight Defensively option when casting spells.
However, as a house rule, you might allow the use of Fight Defensively or Combat Expertise in a way similar to casting on the defensive - the PC makes a Concentration check with DC 15+spell level to pull it off. If he fails the check, he loses the spell.