The only way to be fully protected against this is to delete the messages from the phone, create a backup of the phone and then completely wipe the phone. You can restore the backup afterwards.
Because wiping the phone means that the encryption keys previously used are thrown out and new ones put in place, it is not possible for a (reasonable) attacker to get to the messages even if they should be available in encrypted form on the NAND flash.
If you know the file structure of the app that the messages are saved in, it is possible to create a somewhat weaker defense against outsiders accessing your now-deleted texts. For example if the messages are stored in a SQLite database (such as with for example the Messages app), you could jailbreak the phone, export the database to a dump text file (which wouldn’t contain the deleted messages), remove the original database and then fill up the disk with random bytes. When the disk is filled up, delete the file with random bytes and import your database dump as a SQLite database.
The above mentioned procedure is necessary because when you delete a single message from a SQLite database, it is not a file that is removed. It is merely space within a file that is marked as non-used at the application layer. The file is not shrunk nor does the operating system know that parts of the file are non-used. The above mentioned process forces these deleted areas to be made available to the operating system for overwriting.
In addition overwriting is in itself not a good protection on a NAND flash disk with wear-leveling (i.e. the flash storage in a modern iPhone is comparable to a SSD drive with its own controller, etc.). The reason being that even when you overwrite a data block on disk, the controller inside the flash storage might decide to simply “stow away” that physical block and map other physical blocks in instead. This is a byproduct of wear-leveling.