The joint between a frame and the wall opens and closes as both move. Anything rigid in that joint cracks, which is why filler fails and sealant is used.
Inside or outside
Two different jobs needing two different products.
Internally, the joint is decorative and needs to be paintable. Use decorator's caulk, which is flexible, takes paint and can be smoothed to a crisp line.
Do not use silicone internally where it will be painted, since paint does not adhere to it.
Externally, the joint is weatherproofing and is exposed to sun, rain and movement. Use an exterior grade frame sealant, typically a low-modulus silicone or a hybrid polymer, which stays flexible and resists ultraviolet.
Do not use decorator's caulk outside. It will crack and wash out within a season.
Choosing an external sealant
Low-modulus neutral cure silicone is the usual choice for frame perimeters. It stays flexible, tolerates movement, and does not corrode or stain most substrates.
Avoid acetoxy silicone, the type that smells of vinegar, on masonry, stone and some metals, since it can stain and does not adhere well.
Hybrid polymer sealants adhere well to almost everything, tolerate damp surfaces better and can be overpainted.
Check the sealant is compatible with both surfaces, particularly uPVC, powder-coated aluminium and natural stone.
Preparing the joint
This decides whether it lasts.
Remove all the old sealant. New sealant will not bond to old, and a residue is enough to cause failure. Cut it out with a knife and a scraper, then clean with a solvent wipe.
The surfaces must be clean, sound and dry.
Brush out dust and loose material.
Where the render or masonry is crumbling, repair it first.
Mask both sides if you want a crisp line.
Wide gaps and backer rod
A common cause of failure.
A sealant bead should be roughly twice as wide as it is deep, and it should adhere to two surfaces only, not three.
A bead that fills a deep gap and sticks to the back as well as both sides cannot stretch, and it tears when the joint moves.
Push a foam backer rod into the gap to the correct depth first. It controls the depth of the bead and stops it bonding to the back of the joint.
For very wide gaps, fill with expanding foam, trim it back below the surface, and seal over it.
Applying it
Cut the nozzle at an angle to suit the joint width, starting small.
Work in one continuous movement, pushing rather than pulling the gun, at a steady speed.
Keep enough pressure that the bead fills the joint rather than sitting on top of it.
Tool it immediately with a shaping tool or a wetted finger, in a single pass, which forces it into contact with both faces.
Remove masking tape straight away, before the sealant skins.
Work when the temperature is moderate. Sealant applied in cold or wet conditions cures poorly.
Externally: where to seal and where not to
Seal the perimeter of the frame where it meets the reveal.
Do not seal drainage slots in the bottom of a uPVC or aluminium frame. These let water out of the frame, and blocking them causes water to back up inside.
Do not seal under a sill in a way that traps water behind it.
Leave the drip groove under an external sill clear.
Internally
Caulk the joint between the frame or architrave and the plaster.
Caulk the window board to the reveals.
Smooth with a wetted finger and wipe the excess immediately, since caulk sets quickly and is difficult to remove from a painted wall.
Allow it to skin before painting, and paint over it rather than leaving it bare.
When to reseal
Check external seals annually, particularly on the weather side of the house.
Look for cracking, shrinkage, gaps at the edges, and sealant that has gone hard or chalky.
Resealing before water gets in is far cheaper than dealing with the damp afterwards.
Expect exterior sealant to last some years rather than indefinitely.
Expanding foam
Useful for filling the gap between frame and masonry, and it is not a sealant.
It is not weatherproof and degrades in sunlight, so it must always be covered by a proper sealant or pointing.
Use low-expansion foam around frames, since standard foam can bow a frame as it expands.