Only Show Link If div Exists

This can be done but we need to see the if statement that is around your div. Right now you that code above will still present the div, just not the content IN the div. You need to wrap that link code in the same if statement that your div is in.

example: if your div if statement is:

if ( has_term( 'Accessories', 'product_cat', $post->ID ) ) {
echo '<div class="upsells products" id="tab-accessories">CONTENT OF DIV</div>';
}

wrap your link earlier in the code with the same if statement:

if ( has_term( 'Accessories', 'product_cat', $post->ID ) ) {
echo '<li><a href="#tab-accessories">Accessories</a></li>';
}

whatever happens to one will be the same as the other.