How to customize a title by passing query string?

use the wp_title filter. just remove all your code from header.php and put this into your plugin instead:

add_filter( 'wp_title', 'my_wp_title', 10, 2 );

function my_wp_title( $title, $sep = '|' ) {

    if ( is_page( physician_single_pg() ) and get_query_var( 'doctor' ) ) {
        $doctor = get_query_var( 'doctor' );
        $title = ... // here you put your code to build your title from the doctor & hospital name
    }

    return $title;

}

add_filter( 'query_vars', 'my_query_vars' );

function my_query_vars( $vars ) {

    $vars[] = 'doctor';

    return $vars;

}