The problem you describe is a ground loop. Here is an explaination for what a ground loop is. (Written and copyright by Tomi Engdahl 1997-2000)
---------------------------------------------------------------------------------------------
"A good power distribution system is essential for proper operation of audio system. Professional audio systems just doesn't work well with normal extension cords running hundreds of feet to a stage. Besides the power feed the good grounding of the whole system is essential.
Ground loop is a condition where an unintended connection to ground is made through an interfering electrical conductor. Generally ground loop connection exists when an electrical system is connected through more than one way to the electrical ground.
When two or more devices are connected to a common ground through different paths, a ground loop occurs. Currents flow through these multiple paths and develop voltages which can cause damage, noise or 50Hz/60Hz (variable in car audio due to alternator RPM) hum in audio or video equipment. To prevent ground loops, all signal grounds need to go to one common point and when two grounding points cannot be avoided, one side must isolate the signal and grounds from the other.
Usually ground loops are an after-the-fact type of problem in which the end-user blames the installer, the installer blames the manufacturer, and actually nobody is at fault. Neither the manufacturer nor the installer can usually predict where a loop will occur. Only after the system is installed can it be determined if a problem will exist.
Ground loop problems can be corrected and avoided. It is important for the dealer, isntallee and the end user to be aware that this problem can occur. It is a good idea to design the system to avoid most obvious source of this kind of problems, and then be prepared still to face some problems when starting to use the system. A ground loop problem may occur at several points in the system, and each occurrence of the problem must be corrected individually. "
-------------------------------------------------------------------------------------------------
One thing that usually works is wrapping a small wire around one of the negative prongs on each end of the RCA cable (the outer shield) then grounding the wire to the ground of the headunit and the amp(do it on both ends).
Another thing is to ground the head unit to the same spot as the amp.
These two options connect the grounds of each component together.