It is generally safe to touch the top of a CPU, but you should avoid touching the pins on the underside as they are delicate and can be easily damaged.