The answer is a bit different, depending on whether a sudden illness or sudden death is involved.
If a sudden illness strikesand the goal is to get quick medical help, it is usually advisable to call 911, where operators can usually dispatch the nearest ambulance service. Beware, however, that unless the ill person is wearing a "comfort care only" necklace or bracelet or some other locally-acceptable sign of not wanting heroic life-saving measures to be performed, emergency personnel who are responding are duty-bound to provide them.
If it's a death that occurs at home, the calling hierarchy may depend on whether the death was expected or unexpected.
If the death was expected, call the doctor, although you need not do this immediately, particularly if it occurs in the middle of the night. If you call 911, inform the operator that the death was expected; despite clear signs that death has already occurred, emergency medical personnel will most likely attempt resuscitation. If hospice is involved, notify the on-call nurse.
If the death was unexpected, call 911. The police and emergency medical personnel will determine the next appropriate steps. Under certain circumstances, they may be required to contact the local coroner.