You don't have to query the information_schema.
Just fetch the row as an associative array and output the keys before you output the data:
$row = $STH->fetch(PDO::FETCH_ASSOC);
if ($row) {
fputcsv($fp,array_keys($row));
while ($row) {
fputcsv($fp,array_values($row));
$row = $STH->fetch(PDO::FETCH_ASSOC);
}
}