What this story does is take a proverb that was independently attributed to Jesus and places it within a narrative context; it constructs a story in which the proverb may have been used in order to explore what Jesus may have meant by saying this. The proverb is independently attested in varying forms:
"Jesus said, 'Do not give what is holy to dogs, lest they throw them on the dung-heap. Do not throw pearls to swine, lest they grind it to bits" (Gospel of Thomas 93:1).
"Do not give dogs what is holy, and do not throw your pearls in front of pidgs, or they may trample them and then turn on you and tear you to pieces" (Matthew 7:6).
"But let none eat or drink of your Eucharist except those who have been baptised in the Lord's name. For concerning this also did the Lord say, 'Give not that which is holy to the dogs' " (Didache 9:5).
The proverb originally assumed that the dogs were to be understood as "fools" or "those without wisdom," for similar expressions occur in earlier wisdom literature (cf. Proverbs 23:9; Sirach 22:9-10). Note however that the Didache has interpreted the proverb differently: here the "dogs" are to be understood as the "unbaptised" who eat and drink the Eucharist. This connection to the Eucharist was naturally suggested by the fact that the Eucharist is something very holy (as the flesh of Christ) that is consumed, just as food given to dogs is consumed. But it just isn't any unbaptised person. The Didache was used in the late first century (or early second century AD) as a catechism for Gentile converts to Jewish-Christianity, so the "dogs" were really Gentile converts who partook of the body of Christ though they had not yet been baptised. At the time, the Jews referred to the Gentiles as "dogs"; this usage can be found in an ironic sense in Philippians 3:2 and in rabbinical texts (Niddah 77a; Baba Kama 49a) that liken non-Jews to dogs. For instance, Rabbi Ishmael bar Jose referred to Samaritans as dogs who were "adhesive to idolatrous customs as the dog is to the flesh of carcasses" (Genesis Rabba, 81). This reflects a general attitude that Gentiles were "unclean" from the perspective of purity laws (as dogs were "unclean" animals), and lawless for not abiding to the Torah (cf. Revelation 22:15 in which the "dogs" and murderers and idolators are "everyone of false speech and false life").
The original form of the Matthean story occurs in Mark 7:24-30 (assuming Markan priority and not that the story has been interpolated from Matthew), and there the proverb is given a narrative context. Here the woman is clearly "a Greek, a Syrophoenician by birth" (v. 26), and she begged Jesus to cast out the demon from her daughter. Then Jesus says:
"And he said to her, 'Let the children (tekna) first be fed, for it is not right to take the children's bread and throw it to the puppies (kunariois).' And she answered him, 'Yes, Lord; yet even the dogs under the table eat the children's crumbs' " (Mark 7:27-28).
The highlighted words clearly constitute a version of the same proverb attested in Matthew 7:6 / Gospel of Thomas 93:7 / Didache 9:5, but it differs in wording. The metaphor in this text, of dogs eating crumbs at the table, is seperately attested in rabbinical texts. Rabbi Joshua ben Levi, for instance, referred to the godly as guests invited to the king's table and the unfaithful Gentiles as dogs who ate the crumbs that fell down (Midrash Teh. Psalm 4:8). The word for "dog" in Mark is actually the dimunitive for "puppy," which forms a parallel to the "children" who would otherwise be the recipient of what is thrown. The tekna "children", in the context of Mark (cf. 10:24) are Jesus' disciples, and the text does not clearly say that "children" are only Jewish disciples though it is implied by making the woman's ethnicity so salient. Anyway, in the context of this story, Jesus asserts that his mission to to feeding the "children" (whomever they might be) and they must be fed first before feeding the "puppies", while the woman points out that even while the children are eating, the puppies may still eat the crumbs underneath the table. Thus, the passage makes the argument that even though Jesus' mission was first limited in scope, others may receive blessings from him as well -- despite purity laws (which Jesus flaunts with his healings, cf. Mark 1:23, 5:2, 9:42, etc. and his teaching in 7:1-25).
The Matthean verison, however, is quite different. It is much more elaborate and dramatic. In Mark, the woman approaches Jesus inside a house and Jesus' response about the puppies is quick and direct. But in Matthew 15:21-18, Jesus is outside walking with his disciples and the woman "came outside" (exelthousa) and was following "behind" (ophisthen) them (v. 22-23). Unlike the quick response that Jesus gives in Mark, here "he did not answer her a word," and she had to continue crying behind them so that they would beg him to say something to her. Then Jesus speaks, not to her, but to them by saying: "I was sent only to the lost sheep of the house of Israel" (v. 24). This verse is clearly a Matthean addition, for it is absent in the Markan version of the story, and it occurs also in Matthew 10:6 -- a verse that has no parallel in the other gospels. There Jesus says:
"These twelve Jesus sent out, charging them, ' Go nowhere among the Gentiles, and enter no town of the Samaritans, but go rather to the lost sheep of the house of Israel' " (Matthew 10:6).
The same commission story is given in Mark 6:7-13 and Luke 9:1-6 but nowhere does Jesus make such a demand. In fact, John's gospel presents the exact opposite scenario; there Jesus goes early in his ministry into Samaria and even has a whole Samaritan town become his disciples (John 4:1-42). So much for wasting bread on dogs! Matthew takes the Markan story and makes the identity of the "puppies" much more explicit by inserting the statement from 10:6 into this context. This restricts Jesus' ministry to the "sheep of Israel"; the Gentile ministry would not begin until after Jesus' resurrection (cf. Matthew 28:16-20). John however has Jesus preaching to non-Jews early on and John 10:16 explicitly indicates that the "sheep" were not restricted to the Jews but that Jesus already has "other sheep not of this fold". The story in Mark and especially Matthew thus may constitute an attempt to explain why Jesus' mission was to be limited to the "lost" Jews and yet he still preached and worked miracles with non-Jews. Just like dogs snacking on the crumbs while the children were being fed, so could the Samaritans and Syrophoenicians could have received blessings from Jesus before his death and resurrection opened up salvation to all.
Edited: To provide a link to a relevant article on this:
http://www.infidels.org/library/modern/james_still/syrophoenician.html