Option value not getting updated until page refresh in WordPress

There can be a number of reasons for this, some of which involve db cacheing.

If all this is happening on the same page, the best way to handle it is to eliminate the extra db calls as they are not really necessary anyway. Instead, put the value into a variable (set it as global if necessary to pick it up in another function) and then use the variable instead of get_option(). That way, you only have one db call and one established value.

Also, be sure to sanitize the value before you insert it in the db.

function my_plugin_settings(){
    ?>
    <form method=post>
    <?php

    global $value1;
    if( isset( $_POST['checkbox_value'] ) ) {
          
        $value1 = sanitize_text_field( $_POST['checkbox_value'] );
        update_option('checkbox_value', $value1, $autoload = 'yes');  
    } else {
        $value1 = get_option( 'checkbox_value' );
    }

    ?>
    <input type="hidden" name="checkbox_value" value="no">
    <label><input type="checkbox" name="checkbox_value" <?php 
    checked( esc_attr( $value1 ), 'yes' );
    ?> value="yes"> <?php 
    esc_attr_e( 'Check this box or uncheck it' );
    ?></label></br>
    <div>
        <?php submit_button(); ?>
      </div>
    </form>

    <?php

}

Then, if you have to pick it up elsewhere, use the global value:

global $value1;
if ( 'yes' == $value1 ) {
    echo 'Helloxcaercfwerfgetg5 tcectg3d5euhudheufeuhufhurhf';
}

Update

If what you’re doing involves things that happen before my_plugin_settings() (as noted in the comments), that would certainly explain the problem. Since your OP lacks that context, I can’t address it with specifics, but I can give you a general idea of what you need to look at. You need to make sure that what you’re doing happens in the proper order. Here’s a change to the code you’re using to make sure the value is handled early so that your use of it later can pick things up appropriately.

// Do this early.
add_action( 'admin_init', function() {
    // globalize $value1 so you can pick it up later
    global $value1;
    if( isset( $_POST['checkbox_value'] ) ) {
            
        $value1 = sanitize_text_field( $_POST['checkbox_value'] );
        update_option('checkbox_value', $value1, $autoload = 'yes');  
    } else {
        $value1 = get_option( 'checkbox_value' );
    }
});

function my_plugin_settings(){
    // Wherever you use this needs to happen later than admin_init
    global $value1;
    ?>
    <form method=post>
    <input type="hidden" name="checkbox_value" value="no">
    <label><input type="checkbox" name="checkbox_value" <?php 
    checked( esc_attr( $value1 ), 'yes' );
    ?> value="yes"> <?php 
    esc_attr_e( 'Check this box or uncheck it' );
    ?></label></br>
    <div>
        <?php submit_button(); ?>
        </div>
    </form>

    <?php
}

Now, anywhere you do the following needs to happen later than the admin_init action hook (or you need to use an earlier action for picking up the post value)

// Anything like this needs to happen later than admin_init
global $value1;
if ( 'yes' == $value1 ) {
    echo 'Helloxcaercfwerfgetg5 tcectg3d5euhudheufeuhufhurhf';
}