A comet's tail points away from the sun. Sometimes the dust and gas separate, though, because they are driven by two different effects, radiation pressure and solar wind, respectively. Both point mostly away from the sun, but not always exactly. Photographs of Comet Hale-Bopp show this effect well, for example, the Astronomy Picture of the Day at the link shown. A comet in deepest cold space is generally thought of as a giant dirty snowball with the snow made of water ice, and frozen organic liquids, and the dirt of small rocks and dust which are the debris of explosions and collisions of different bodies in space. It is only when the comet approaches the sun and warms up that surface ice melts and vapourises carrying dust with it and forming a large cloud that we can see clearly. It is at this stage when the effects mentioned above act on the cloud and sweep it behind the comet relative to the sun to form a tail or tails, and because there is no atmospheric air in space the tail always points away from the sun even when the comet is travelling away from it.