When does the Pope speak ex cathedra? The Catholic Church considers the Pope infallible, but only in limited circumstances. The Pope is a human being like the rest of us, and capable of sinning. However, when the Pope speaks ex cathedra, i.e. with papal authority, he is infallible.

How do Catholics know when the Pope speaks ex cathedra?
Vatican I defined it.
A true pope (not an antipope or heretic claiming to be the pope), when speaking on a matter of faith or morals (not economics or science) when speaking to the universal Church (not a letter to a friend) is guided by the Holy Spirit.

when the Roman pontiff speaks EX CATHEDRA,
that is, when,

in the exercise of his office as shepherd and teacher of all Christians,
in virtue of his supreme apostolic authority,
he defines a doctrine concerning faith or morals to be held by the whole church,