Both are widely regarded as pests and neither eats plants. The problems they cause are indirect, and for most of the year both are doing work worth having.
What ants actually do
Ants do not feed on living plants.
They aerate soil, break down organic material, and prey on a considerable number of small insects including some pests.
The genuine problems are indirect:
They farm aphids, scale insects and mealybug for the honeydew these produce, and actively defend them from ladybirds, lacewings and parasitic wasps. An ant trail up a stem usually means a sap-sucking colony above.
Their nests disturb roots. Fine soil heaped around the roots of a plant in a dry summer, particularly in a container or under a paving slab, can cause wilting.
Nests in lawns produce fine soil heaps that are scattered by the mower and spoil the surface.
They undermine paving by excavating sand from joints.
Dealing with ants
Deal with the aphids or scale rather than the ants, and the ants lose interest.
A sticky barrier or grease band around a stem or a pot prevents them climbing to their livestock.
On a lawn, brush the heaps flat and dry on a dry day before mowing, rather than mowing them wet, which smears soil across the grass.
Water containers thoroughly, since a nest in dry compost is a drainage and drying problem more than a pest problem.
Where a nest is in an inconvenient place, repeated disturbance often persuades a colony to move.
Chemical treatments are rarely necessary outdoors, and boiling water poured on a nest is crude, kills other soil life and damages plant roots.
Flying ants on a warm day in summer are the mating flight. It lasts a day or two and needs no response.
What wasps actually do
For most of the year social wasps are among the most useful predators in a garden.
Through spring and early summer they hunt enormous numbers of aphids, caterpillars and other insects to feed their larvae. A single nest removes a considerable quantity of pests over a season.
In return the larvae feed the adults a sugary secretion.
Why they become a nuisance
By late summer the colony stops rearing young. The adults lose their sugar supply and switch to seeking sweet things: fallen fruit, drinks, jam and anything else available.
That is when they become an irritation at a table and start damaging ripe fruit.
They generally enlarge existing damage rather than breaking undamaged skin, so bird and codling moth damage frequently comes first.
Living with them
Pick fruit promptly and clear windfalls.
Cover food and drinks outdoors, and check glasses and cans before drinking.
Avoid sweet traps and jars of jam and water. They kill very large numbers of wasps and hoverflies without meaningfully reducing the nuisance.
Stay calm rather than flapping, since sudden movement provokes them.
Wear shoes on a lawn with fallen fruit.
Nests
A nest away from where people go is best left alone. Colonies die out entirely in autumn and the nest is never reused.
Where a nest is beside a door, in a shed used daily, or where someone is allergic, it is worth dealing with.
Do not attempt to treat a nest yourself. Disturbed colonies attack in numbers, and people are seriously injured every year. Use a professional pest controller.
Never block the entrance, which drives them into the building instead.
Stings and allergy
Most stings are painful rather than dangerous.
Anyone with a known severe allergy should carry their prescribed treatment, and anyone showing difficulty breathing, swelling of the face or throat, or faintness after a sting needs emergency medical help immediately.
Solitary bees and wasps
Most species are solitary, do not defend a nest, and rarely sting. They are excellent pollinators and predators and should simply be left to get on with it.
Mason and leaf-cutter bees nesting in an insect hotel or a wall are entirely harmless.
Hornets
Larger than wasps and generally less aggressive, and the European hornet is a valuable predator that is best left alone.
The Asian hornet is a serious threat to honeybees and other pollinators, and suspected sightings should be reported to the relevant authorities rather than tackled directly.