Call add_action() in function wordpress

You’re thinking about this entirely wrong. A meta tag isn’t something you add when a post gets saved, it’s something that gets added to the output when a post is viewed.

So instead of trying to hook the action inside save_post, you hook it on every page load, and inside the hook you check if your custom field exists on the post being viewed. If it is, you output the tag.

function wpse_283352_add_meta_tag() {
    if ( is_singular() {
        $post_id = get_queried_object_id();
        $meta = get_post_meta( $post_id, '_my_custom_field', true );

        if ( $meta ) {
            echo '<meta name="my_custom_field" content="' . esc_attr( $meta ) . '">';
        }
    }
}
add_action( 'wp_head', 'wpse_283352_add_meta_tag' );

That function just goes in your plugin file/functions file, not inside any other hook.

tech