To use an electric guitar with GarageBand, is a USB cable necessary?
An electric guitar produces an analogue audio signal which passes through an amplifier and out to speakers.
To connect the guitar to a computer you will have to link it with an analogue cable either direct from the guitar's output jack and into the computer's microphone socket, or into an amplifier then from the amplifier's line out socket into the computer's line in socket. DO NOT connect the line out into the microphone, or the speaker out into the computer in any way at all, or you may well damage your soundcard.
Be warned - connecting the guitar to the microphone socket will probably give quite ropey results. If you are hoping to create something of any reasonable quality you would be best off investing in a decent sound-input device (most of which are USB).
Personally I use one of these: http://www.ionaudioshop.co.uk/ion-u-record-mixmeister/ which I connect my small mixing desk to. They do alot of other similar devices too.
No as long as you have a Line in port on your computer you can connect your guitar directly to it. This wont give you a very nice sound but it works. It works even better if you have a little preamp in between to boost the signal.
On the computer you can use for example guitarrig or guitarfx to get cool sounds. This should be enough for an easy quick recording.(which I guess is what you are going to do since you are using garageband)
Of course a good audio interface,with firewire/USB will give much better results but it can be done without one as long as you have the line in port.