The problem here is that you're trying to format a number with three decimal places with a function that only gets two.
So, you should do this:
$tottax = ($subtot * $taxrate);
list($a, $b) = split(".", $tottax); // splits the "decimal" part
$leng = strlen($b); // Length of "decimal" part
$tottax = number_format($tottax, $leng); // format with any numer of elements
echo "$".$tottax;
Hope it helps