Technically this is not a *weather* category question. However:
If inside:
* In most cases, DO NOT RUN OUTSIDE. Read the rest of this answer to see why.
* Get under a sturdy frame, such as a table door frame. This will protect you more than trying to run outside. Buildings can collapse in a matter of seconds.
* Curl into a ball and cover your face and front of your body with your arms. This will protect you from the next item:
* Get away from objects that will harm you if they fall or break, such as windows, large appliances, sharp objects, etc. This is another reason not to run outside, as you will have to pass many dangerous objects in a quake.
* Get out of the building after the quake if you feel there will be a fire or gas leak or other danger. Do this ONLY if you're sure it's safe to come out from under your cover.
If outside:
* Get away from objects that are likely to fall on you (bricks on a building exterior, power lines, rock walls, etc.)
* Get away from traffic, where people may swerve off the road in panic
* This is probably the safest place.
In all cases:
* Take quick action: things don't take long to happen in an earthquake. Fractions of a second may be all you have. This is why you usually shouldn't run outside.
* Keep your head, and don't panic.