will wp_insert_post write a new custom field to the database?

Yes, wp_insert_post() will automatically insert new postmeta as well.

I just tried out your exact code and it worked. And the reason behind this could be quite simple: In WordPress, meta info for a post is only a key and value pair. There is no strict rule that keys have to be defined somewhere, so you can easily insert your own at any given moment.