WooCommerce – Complete Order when an action occurs

Remove return; from your code, which is prematurely exiting the function before the following two lines can be executed; that is why the status is not changed.

function my_change_status_function () {     
    global $post;
    $ordernumber = get_post_meta( $post->ID, 'order_number', true );
    $audit_status = get_post_meta( $post->ID, 'audit_status', true );    
    if ( $audit_status == 'Complete' ) {   
        $order = new WC_Order( $ordernumber );
        $order->update_status( 'completed' ); 
    }    
}
add_action( 'save_post_audits', 'my_change_status_function' );

error code: 523