According to the Minecraft WikiMinecraft Wiki:
A fire block can turn any air block that is adjacent to a flammable block into a fire block. This can happen at a distance of up to one block downwards, one block sideways (including diagonals), and four blocks upwards of the original fire block.
So anything 4 blocks underground should be fine.
Also, from plenty of experience in the game, I can assure you that only blocks marked as flammable will ignite. To check this, search for the block on the Minecraft Wiki and look for the flammable tag in the block info.