The following comes from the Women of Faith and Family:
The devotion to the Immaculate Heart of Mary is connected on many points with that to the Heart of Jesus; nevertheless, it has its own history. The attention of Christians was early attracted by the love and virtues of the Heart of Mary, symbolized by her heart.
Simeon's prophecy in Luke 2:33-34 paved the way and furnished devotion with one of its favorite formula and most popular representations: the heart pierced with a sword. Saint Luke's Gospel says that Mary kept all the sayings and doings of Jesus in her heart, that she might ponder them and live by them.
Indications of a regular devotion are perceived in a sermon by Saint Bernard (d. 1180), De duodecim stellis, from which extract has been taken by the Church and used in the Offices of Compassion and of the Seven Dolors. Stronger evidence is discernible in the pious meditations on the Ave Maria and the Salve Regina, usually attributed to Saint Anselm of Lucca (d. 1080) or Saint Bernard.
Saint Jean Eudes (d. 1681) propagated the devotion to make it public, first in Autun in 1648 and afterward in a number of French dioceses. He established religious societies interested in upholding and promoting devotion. His efforts to secure a feast failed in Rome but the devotion progressed. In 1699 Father Pinamonti (d. 1703) published in Italian his beautiful little work on the Holy Heart of Mary, and in 1725 Pere de Gallifet combined the cause of the Heart of Mary with that of the Heart of Jesus in order to obtain Rome's approbation of the two devotions and the institution of the two feasts. In 1729 his project was defeated, and in 1765 the two causes were separated, to assure the success of the principal one.
In 1799 Pius VI, then in captivity at Florence, granted the Bishop of Palermo the feast of the Most Pure Heart of Mary for some of the churches in his diocese. In 1805 Pius VII made a new concession, thanks to which the feast was soon widely observed. In 1942, Pope Pius XII consecrated the world to the Immaculate Heart of Mary.