In his recent show Content Provider, Stewart Lee talks of the perils of trying to write topical material: if a joke or routine is truly topical, then it lacks the kind of longevity needed for a typical stand-up tour, the comedian running the risk of finding themselves suddenly overtaken by events.
More general shifts in attitudes in wider society can also affect comedy, though. In this article for Vulture, an assortment of American comics including "Weird Al Yankovic" and Patton Oswalt talk about jokes that, with the benefit of hindsight, they regret writing and performing because times have moved on.
When comedians are young, nervous and desperate to make an impression, missteps are inevitable, even if neither the stand-ups nor their audiences recognise them as such at the time and they only become glaringly obvious with the passage of time. The broad consensus of those interviewed is that comedians can only grow as performers if they're prepared to reflect critically on their old material, which can include acknowledging its contemporary unacceptability. It might be impossible to avoid feeling a tinge of regret at certain jokes, but you can guard against it by focusing on being true to yourself and your craft rather than merely seeking to cause offence.
(Thanks to Ian for the link.)