Set post terms on post publish

The argument from pending_to_publish action, $post_id in your case, is not ID but array (callback to publish).

I think it would be better to use the publish_post action, that way $post_id will actualy be the post id.

Also this is a very general action so if you have multiple post types it would be wise to check if the current post type is the actual one you want to add the term to

Edited answer

Or in your case you can pass the post id as following

add_action('pending_to_publish', 'oj_publish_post');
function oj_publish_post($post) {
  $taxonomy = 'category';
  $term_id = array(8);
  $term_id = array_map('intval', $term_id);    
  wp_set_post_terms( $post->ID ,$term_id, $taxonomy,true);
}