How long until tamed wolves stop attacking in Minecraft?

Solution 1:

From the Minecraft wiki (emphasis mine):

Angry wolves have a constant growling and fearsome appearance. Wild wolves become hostile when they are either attacked by a player or mob, or when they see a mob they want to eat. Their tail is held out straight, their eyes become blood red, their mouth is raised in a slight snarl, and they have angry eyebrows. Angry wolves are hostile only to mobs that attack them, or the mobs which they are hunting. They can see attackers even if they are under the invisibility effect, but they cannot track the attacker down, if they get out of their render distance, or the attacker was able to unload the chunk where the wolves were. Angry wolves cannot be leashed, but a wild wolf may become angry while it is still leashed without dropping the lead.

Since, in your situation, the target is a Golem, the best way to manage this would be to travel away from the golem quickly, and allow your wolf to teleport with you (emphasis mine):

Teleporting resets the focus of a tamed wolf, so if a wolf is attacking a mob and teleports beside a player, it resumes following the player, as its tracking has been reset.

Additionally, you have to allow the wolf to teleport with you. It will not teleport:

  • If the wolf has been ordered to sit.
  • If the wolf is in a minecart or a boat.
  • If the wolf has been attached to a fence post with a lead.
  • If the wolf is in an unloaded chunk.
  • If the owner is not directly touching the ground (e.g. using elytra, swimming, flying, in a boat).