You need to reset the query, so a full working code would be:
<?php
query_posts('cat=5');
if (have_posts()) : while (have_posts()) : the_post();
echo('<li><a href="');
the_permalink();
echo('">');
the_title();
echo('</a></li>');
endwhile; endif;
//Reset Query
wp_reset_query();
?>
And that should do it. You can see this article in the Codex for more info