How to add a custom field to a post created programmatically?

You have created a custom field by altering the post table in the database. Custom fields in WordPress API are considered meta fields; such fields are stored in wp_postmeta table and that is the table used by functions like add_post_meta() and the rest of the functions and methods related with post custom/meta fields.

You can check how to work with meta/custom fields in the MetaData section of plugin developer handbook.

PD: Altering core database tables is considered a very bad practice.