You shouldn't have allowed the placement in the first place
The rules for placement of an Eldritch cannon are finite:
At 3rd level, you learn how to create a magical cannon. Using woodcarver's tools or smith's tools, you can take an action to magically create a Small or Tiny eldritch cannon in an unoccupied space on a horizontal surface within 5 feet of you. A Small eldritch cannon occupies its space, and a Tiny one can be held in one hand.
As there are no hidden rules, nothing allows an Eldritch Cannon to be placed inside of another creature. You even have to create it in an unoccupied space in the first place. In fact, achieving such positioning is precluded in the first place, as you can only move through other creature's space, but never end your movement in the same space:
Whether a creature is a friend or an enemy, you can’t willingly end your move in its space. - PHB p191
Even the Grappling maneuver does not make two characters share one space but puts them into adjacent ones.
Since you can't put the cannon in the mouth (that would be willingly ending in the square) in the first place, this should technically moot the question.
Only if the enemy would try to swallow the cannon or otherwise ingest it with some feature it could end up in the mouth under the rules.
Ok, you did it, what now?
Well, for some reason or another it happened anyway. How to rule now? Well, the closest similarity to what the cannon in the mouth reflects is the Shambling Mound's engulf feature:
Engulf: The shambling mound engulfs a Medium or smaller creature Grappled by it. The engulfed target is Blinded, Restrained, and unable to breathe, and it must succeed on a DC 14 Constitution saving throw at the start of each of the mound's turns or take 13 (2d8 + 4) bludgeoning damage. If the mound moves, the engulfed target moves with it. The mound can have only one creature engulfed at a time.
That's... BAD: Treating the cannon in the mouth as Engulfed means it is blinded, restrained, takes bludgeon damage and also grappled. Luckily being Grappled don't technically preclude a ranged attack (Grappled condition only puts the speed to 0), but Restrained gives automatic Disadvantage on the Attack of the cannon, and then there is Disadvantage from shooting point-blank... which luckily only accounts for simple Disadvantage, because it doesn't stack.
You might feel inclined to grant a simple Advantage for the good position to counter the Disadvantage from being technically Grappled and Point Blank, resulting in a normal Attack Roll.
So the ruling of the cannon placement should have been: "You can't do that, only the enemy can try to gulp down your gun."
In case you allowed it anyway (or it happened on the volition of the enemy), the ruling now should be, because of the conditions that should apply (restrained) and that automatically apply (point blank ranged attack), that there has to be an attack roll with Disadvantage or, if you are particularly mercyful, a normal one.