Think of the embassy as your country's help desk abroad, and contact it whenever a situation exceeds what you can fix with money and a phone. The clear-cut cases: arrest or detention, where you should ask police to notify your consulate, a right in most countries; a lost or stolen passport; serious accident or hospitalization, where consuls can contact family, help find medical care, and assist with insurance logistics; death of a travel companion; becoming a victim of serious crime; and natural disasters, civil unrest, or evacuations, when the embassy coordinates citizen safety and departures.
Slightly less obvious but valid: running completely out of money through theft, where consuls can help family transfer funds; forced marriage or domestic abuse situations abroad; child custody emergencies; and needing lists of local lawyers, doctors, or translators, which consulates maintain.
Register your trip with your embassy's traveler program where one exists, since that is how they reach you in a crisis, and store the emergency consular number in your phone, as most countries staff an after-hours line for genuine emergencies. What embassies cannot do is also worth knowing, no paying your bills, overriding local law, or getting you out of jail, so contact them early for guidance rather than expecting rescue.