Solved, thanks! :-)

;;;_ borrar todas las etiquetas al cambiar el estado a HECHO
(defun borrar-etiquetas-tareas-hechas (plist)
  "Borra todas las etiquetas al cambiar una tarea a =HECHO=."
  (when (eq (plist-get plist :type) 'todo-state-change)
    (when (string= (plist-get plist :to) "HECHO")
      (org-set-tags-to nil))))

(add-hook 'org-trigger-hook 'borrar-etiquetas-tareas-hechas)

El 27/06/2023 a las 14:05, Ihor Radchenko escribió:
Ypo <ypuntot@gmail.com> writes:

I have tried gptel inside emacs (I'm sorry, but I need to tell it) and I 
got this code:

#+begin_src emacs-lisp
(defun my-org-trigger-function (state)
   "Remove all tags when state changes to 'DONE'"
   (when (string= state "DONE")
...
(add-hook 'org-trigger-hook 'my-org-trigger-function)
#+end_src

Surprisingly 8-) it doesn't work. Any help?
org-trigger-hook is a variable defined in org.el.

Documentation
Hook for functions that are triggered by a state change.

Each function gets as its single argument a property list with at
least the following elements:

 (:type type-of-change :position pos-at-entry-start
  :from old-state :to new-state)

Depending on the type, more properties may be present.