How to detect and make links nofollow in author description

This is really more of a general PHP question, but this will do the trick:

$author_desc="<div class="td-author-description">";
$author_desc .=  get_the_author_meta( 'description', $author_id );
$author_desc .= '</div>';

$dom = new DOMDocument;
$dom->loadHTML( mb_convert_encoding( $author_desc, 'HTML-ENTITIES', 'UTF-8' ) );

$sxe = simplexml_import_dom( $dom );

// Process all <a> nodes with an href attribute
foreach ( $sxe->xpath( '//a[@href]' ) as $a) {
    if ( empty( $a['rel'] ) ) {
        $a['rel'] = 'nofollow';
    } else {
        $a['rel'] .= ' nofollow';
    }
}

$author_desc = $dom->saveHTML();

$buffy .= $author_desc;

Replace the original code in your question with the code in this answer (this is based on the full code that you posted here).

Code adapted from this answer on Stack Overflow. Encoding fix via this post.