The uttering of "La Illaha ila Allah" does not benefit except for the one who knows its meaning, acts according to what it necessitates and does not commit shirk!

The uttering of the two testifications (that there is no deity worthy of worship truly except Allah, and that Muhammad - may Allah send peace and blessings upon him - is the messenger of Allah) is not a preventer from the takfeer except for the one who;

knows their meaning,

acts according to what they necessitate,

does the worship purely for Allah and does not associate others with him in worship,

...for this one the two testifications are of benefit.

And as for the one who pronounces them and no compliance to what they necessitate occurs from him, but rather (he) associates partners with Allah in worship, takes intermediaries and intercessors besides Allah and asks from them what no one is able to do except Allah, offers sacrifices for them and does for them what the people of jahiliyyah from the mushrikeen do; then for this one the two testifications are of no benefit, rather he is a liar with regards to his testification, as Allah (The Perfect and Most High) mentions:

{When the hypocrites come to you (O Muhammad, may Allah send peace and blessings upon him), they say: "We bear witness that you are indeed the Messenger of Allah." Allah knows that you are indeed His Messenger and Allah bears witness that the hypocrites are liars indeed.} [Surah Al-Munafiqun 63:1]