Asalaam Alaikum
to find an answer to your question, let us examin the verse and the incident separately. in the books of tafsir, there are mentions about when the verse 9:5 (verse of the sword) was revealed and in books of history it is mentioned the incident of destruction of dhul-khalasa. let us try to find a time-lime, insha Allah.
in the tafsir of ibn kathir,
The first part of this honorable Surah was revealed to the Messenger of Allah when he returned from the battle of Tabuk, during the Hajj season, which the Prophet thought about attending.
now if we try to find the when the battle of tabuk took place, in the books of islamic history it is mentioned 9 AH, that is 630 AD. (in some books it is mentioned that it was the month of october/rajab)
now let us look at the incident of dhul-khalasa. in the books of islamic history it is mentioned that this incident occured on 10 AH, that is 632 AD. (here i found no relevant month mentioned)
from this we can understand for ourselves if the verse or hadith precedes, insha Allah.
(note : this research was purely my own and if there is any mistake, its by me. may Allah help me.)
may Allah the mighty and sublime grant us mercy and guide us to the straight path.
Allah knows best.
REFERENCE :
- tafsir of the quran by ibn kathir
- al-bidaya wa'l-nihaya by ibn kathir
- al-sira al nabawiyya by ibn kathir
- atlas of the islamic conquests published by darussallam