The first three lines of your code belong in a controller file. I have no idea where you're putting this so you need to figure out which controller file to use for that corresponds to the twig file template it should appear in.
So this part goes into whatever controller file you're using.
$doc = new DOMDocument();
$doc->loadHTML(mb_convert_encoding($blog['description'], 'HTML-ENTITIES', 'UTF-8'));
$yourText = $doc->saveHTML();
Next, you need to find your corresponding view template (.twig) file and you can echo $yourText by including where ever it's supposed to be with:
{{ yourText }}