Often heat, but...
If you've acutely injured your back (strain, contusion/bruise, etc) then cold compresses for the first few days will probably help.
If this is a chronic recurrent problem, pain related to muscle spasm
and tension then often a heating pad
, warm showers
can be helpful. Don't forget proper posture, gentle stretching and core strengthening as well.