INSERT in table row fatal error

This is more or less a programming question. $wpdb is not available everywhere. It’s a global variable. If you want to use it inside your own functions, just add global $wpdb; at the first line of the function.

For general programming questions, this might be another discovery for you: stackoverflow.com,it is about programming in specific. Regardless being PHP (as with wordpress plugins) or javascript stuff.

But for your wordpress problem, here is the code in full:

function post_votes($post_ID)  { 
 global $wpdb;
 $wpdb->insert( $wpdb->prefix . 'post_votes', array( 'post_id' => $post_ID ) );
    return $post_ID;
}

add_action ( 'publish_post', 'post_votes' );