Auto delete comment if Contains

It is better to use ‘comment_post’ action for this purpose, it is fired when the comment is saved in database:

add_action('comment_post', 'my_comment_post_callback', 10, 3);

function my_comment_post_callback($comment_id, $comment_approved, $commentdata) {
    if (strpos($commentdata['comment_content'], 'dog') !== false) {
        $post_url = get_permalink($commentdata['comment_post_ID']);
        wp_delete_comment($comment_id, true);
        wp_redirect($post_url);
        exit;
    }       
}