I believe you are looking for the following function
<?php echo get_category_parents( $cat, true, ' » ' ); ?>
where $cat is the id of the current category. This example if from the codex https://codex.wordpress.org/Function_Reference/get_category_parents