As for the distribution of the spoils of war, there's no prescription on where to do it. It is up to the Muslim leader to decide when the right moment is for that. However, it can only be done if the fight/war is over.
In other words, it can be done in Dar al-Harb.
This is supported by the known hadith on 'Azl for slaves (See for example here in Sahih al-Bukhari) you may also refer to books on Sira like Mubarakpuri's ar-Raheeq al-Makhtoom.
You may read in al-Mawsu'a al-Fiqhiyya (see here):
.مكان قسمة الغنائم:
Place of dividing the spoils:
يَقسم الإمام الغنائم حسب المصلحة.
The imam divides the spoils according to interest.
فله أن يقسمها بين المسلمين المقاتلين في دار الحرب بعد انهزام العدو كما قسم النبي صلى الله عليه وسلم غنائم بني المصطلق في بلادهم، وكما قسم غنائم خيبر فيها.
He may divide it among the Muslim fighters in the land of war after the defeat of the enemy, just as the Prophet, may God’s prayers and peace be upon him, divided the spoils of Banu al-Mustaliq in their country, and just as he divided the spoils of Khaybar there.
وله أن يقسم الغنائم في طريقه إلى بلده كما قسم غنائم حنين في الجعرانة قرب مكة، وكما قسم الغنائم بذي الحليفة قرب المدينة.
He may divide the spoils on his way to his country, just as he divided the spoils of Hunayn in Al-Ja'ranah, near Mecca, and just as he divided the spoils in Dhu Al-Hulayfa, near Medina.
See also in Sahih al-Bukhari:
Narrated Ibn 'Aun:
I wrote a letter to Nafi' and Nafi' wrote in reply to my letter that the Prophet (ﷺ) had suddenly attacked Bani Mustaliq without warning while they were heedless and their cattle were being watered at the places of water. Their fighting men were killed and their women and children were taken as captives; the Prophet (ﷺ) got Juwairiya on that day. Nafi' said that Ibn 'Umar had told him the above narration and that Ibn 'Umar was in that army.