How do I group results from wp-query

Need to track the previous job title, and if it’s different, insert your line break.

Untested:

$prev_job_title = null;

while ( $staff->have_posts() ) {
    $staff->the_post();

    $job_title = get_post_meta( get_the_ID(), 'job_title', true );

    if ( $prev_job_title !== $job_title ) {
        printf( '<h2>%s</h2>', esc_html( $job_title ) );
        $prev_job_title = $job_title;
    }

    // Staff markup.
}

tech