The ankheg can make an unarmed attack that deals 4 damage.
Any creature can make an unarmed attack dealing damage equal to 1 + its Strength modifier.
From page 17 of version 2.3 of the Sage Advice Compendium, which are considered official rulings:
What actions can monsters use to make opportunity attacks? Are Multiattack and breath weapon actions allowed?
A monster follows the normal opportunity attack rules (PH, 195), which specify that an attack of opportunity is one melee attack. That means a monster must choose a single melee attack to make, either an attack in its stat block or a generic attack, like an unarmed strike. Multi-attack doesn’t qualify, not only because it’s more than one attack, but also because the rule on Multiattack (MM, 11) states that this action can’t be used for opportunity attacks. An action, such as a breath weapon, that doesn’t include an attack roll is also not eligible.
The ankheg can arguably drop the grapple to make a bite.
Technically, an opportunity attack triggers right before the opponent moves out of range, and must be taken at that point, no matter what state the ankheg is in. If they're still grappling when it happens, as I read it, the letter and intent of the rules are both clear: no bitey.
However, a grapple can be ended at any time, "no action required", which in Jeremy Crawford's opinion, refers to something which can be done even on an opponent's turn. Since it requires no action, doing so does not consume a reaction, which is handy because the ankheg needs to use a reaction to make an opportunity attack.
But the ankheg could, in theory, drop the grapple in response to "a character starts to move away from me" and the opportunity attack would still trigger in response to "a character is about to move out of reach".
For reference, monsters can in general make unarmed strikes
Monster Manual p. 11 states, under "Actions":
When a monster takes its action, it can choose from the options in the Actions section of its stat block or use one of the actions available to all creatures, such as the Dash or Hide action, as described in the Player's Handbook.
"Actions in Combat", PHB p. 192-193, includes Attack as one of those options:
The most common action to take in combat is the Attack action, whether you are singing a sword, firing an arrow from a bow, or brawling with your fists.
Rules for unarmed attacks appear on page 195, and per the errata, the rules for this are as follows:
Instead of using a weapon to make a melee weapon attack, you can use an unarmed strike: a punch, kick, head-butt, or similar forceful blow (none of which count as weapons). On a hit, an unarmed strike deals bludgeoning damage equal to 1 + your Strength modifier. You are proficient with your unarmed strikes.