He has had this ability because he hosted a part of Voldemort's soul:

> 
> “Tell him that on the night Lord Voldemort tried to kill him, when Lily
>  cast her own life between them as a shield, the Killing Curse rebounded upon
>  Lord Voldemort, and a fragment of Voldemort’s soul was blasted apart from the
>  whole, and latched itself onto the only living soul left in that collapsed building.  
> 
> **Part of Lord Voldemort lives inside Harry, and it is that which gives him the
>  power of speech with snakes**, and a connection with Lord Voldemort’s mind
>  that he has never understood. And while that fragment of soul, unmissed by
>  Voldemort, remains attached to and protected by Harry, Lord Voldemort cannot
>  die.”  
> 
> *(Deathly Hallows, Chapter 33, The Prince's Tale)*
> 
> 
> 

But now that Voldemort is fully dead, there's no reason why he would still be a Parselmouth.

In fact, this is confirmed in Pottermore:

> 
> Harry can no longer speak it  
> 
>  Harry being an accidental Horcrux meant he was bound to Voldemort in so many ways, just like Voldemort was bound to serpents. Not only could Harry speak the language of the snake, but could see through the eyes of Nagini, another of Voldemort’s Horcruxes as it turned out.  
> 
>  Once the part of Voldemort’s soul that dwelled inside Harry was destroyed, however, Harry discovered he was no longer a Parselmouth; an added bonus of Voldemort’s demise.  
> 
> *<https://www.pottermore.com/features/everything-you-didnt-know-about-parseltongue>*
> 
> 
> 

This conclusion is also reached [here](https://scifi.stackexchange.com/questions/37252/did-harry-potter-lose-voldemorts-powers-when-he-stopped-being-a-horcrux) and [here](https://scifi.stackexchange.com/questions/27613/would-harry-still-be-a-parselmouth-at-the-end-of-the-deathly-hallows).

So, why is he able to speak Parseltongue in the Cursed Child?