While earthquakes can occur almost anywhere, they are most common around the edges of the great tectonic plates of the Earth's crust. The plates are always in motion, and the edges tend to rub up against one another, building up the energy that results in an earthquake.
Earthquakes occur around fault lines, which are areas where two plates, or two segments of a plate, are moving in different directions. They may be sliding against each other in opposite directions, or one may be forcing its way under the other. In either case, areas of contact occur where the edges of the fault rub against each other and stop moving. The rest of the plates continue to move, building up potential energy. When the two edges build up enough pressure to force their way free, the resulting vibration is an earthquake.
The edges of the Pacific Plate are notorious sources of earthquake activity. The Pacific Plate contacts the North American Plate along the western coast of the United States, which is one of the reasons for the large amount of earthquake activity in California. It extends across the ocean to Japan, where it contacts the Eurasian and Philippine Plates. The borders of this plate are sometimes also called the Ring of Fire; the same geologic processes that produce earthquakes can also produce volcanic eruptions.