In what official document/thing was ecumenical councils declared infallible?
It was articulated at the Second Vatican Council, in the Constitution Lumen Gentium. It was taught consistently by the ordinary Magisterium before that and has been the common belief of the Church. It has also been reflected in the Church's consistent praxis, which has required the unconditional assent of faith to definitive teachings of Councils (if the Council could err in these teachings, the assent would have to be conditional).
Although the individual bishops do not enjoy the prerogative of infallibility, they nevertheless proclaim Christ's doctrine infallibly whenever, even though dispersed through the world, but still maintaining the bond of communion among themselves and with the successor of Peter, and authentically teaching matters of faith and morals, they are in agreement on one position as definitively to be held.(40*) This is even more clearly verified when, gathered together in an ecumenical council, they are teachers and judges of faith and morals for the universal Church, whose definitions must be adhered to with the submission of faith.(41*)
And this infallibility with which the Divine Redeemer willed His Church to be endowed in defining doctrine of faith and morals, extends as far as the deposit of Revelation extends, which must be religiously guarded and faithfully expounded. And this is the infallibility which the Roman Pontiff, the head of the college of bishops, enjoys in virtue of his office, when, as the supreme shepherd and teacher of all the faithful, who confirms his brethren in their faith,(166) by a definitive act he proclaims a doctrine of faith or morals.(42*) And therefore his definitions, of themselves, and not from the consent of the Church, are justly styled irreformable, since they are pronounced with the assistance of the Holy Spirit, promised to him in blessed Peter, and therefore they need no approval of others, nor do they allow an appeal to any other judgment. For then the Roman Pontiff is not pronouncing judgment as a private person, but as the supreme teacher of the universal Church, in whom the charism of infallibility of the Church itself is individually present, he is expounding or defending a doctrine of Catholic faith.(43*) The infallibility promised to the Church resides also in the body of Bishops, when that body exercises the supreme magisterium with the successor of Peter. To these definitions the assent of the Church can never be wanting, on account of the activity of that same Holy Spirit, by which the whole flock of Christ is preserved and progresses in unity of faith.(44*)