In Matthew 15:21-28, Jesus said He was sent only to the Jews.
But after His resurrection, He sent His disciples to all nations. Why did Jesus change his mind?
Also in that passage, Jesus called the non-Jews "dogs." Then he changed his mind and wanted to deliver His message to the "dogs" also?
There are two ways to answer your question. One is on a historical basis, the other on a literary basis.
Historically speaking, it is possible that Jesus changed his mind, that is, that having started his ministry focusing only on Israel he then expended it to include the Gentiles, something that was already envisioned in the Hebrew Bible (cf. Isaiah 42:6, 49:6, 52:10).
Now, in regards to Jesus addressing the woman with such an offensive language it has to be said that, disappointing as it may be to many of us who thought that Jesus was above ethnic and religious prejudices, he was behaving as a typical 1st Century Jew for whom Gentiles were as unclean as dogs. But the truth is, we don't really know what Jesus said, only what Matthew, following Mark 7:24-30, reports him as saying. We can't hear Jesus' voice. We can only read it in Matthew's narrative. We can only have access to the literary constructed Jesus, not the Jesus of history.
Therefore, literaily speaking, this all can be explained as the work of Matthew, the evangelist, who by the time he wrote his gospel, around 80 or 90 CE, knew that the Jesus movement had expanded to include non-Jews. That is why, in chapter 28:19, he has Jesus commissioning his disciples to preach the gospel to all the nations. And of course the word he uses in Greek is the same used for Gentiles. Regardless of if the historical Jesus changed his mind or not, Jesus, the character in Matthew's story, did!