How do you copy a TDE-encrypted SQL Server database using T-SQL programatically?
Using just T-SQL?  Probably but not easily.  A much better solution would be to simply put the certificate for the database on the destination server so that you can restore the database as needed to the destination server.

Given that your database has TDE enabled, I assume that there's PII in there that you have to keep encrypted.  By moving it to another server without encryption you've probably just broken your data encryption policy.