The terms can be used synonymously, but historically there are nuances involved...
Let us firstly recall that at the end of the First Epistle to the Corinthians, 16, 22, St. Paul says: "If any man love not our Lord Jesus Christ, let him be anathema, maranatha!"
Anathema now is equal to a major excommunication.
In the New Testament anathema no longer entails death, but the loss of goods or exclusion from the society of the faithful. St. Paul frequently uses this word in the latter sense. In the Epistle to the Romans (9:3) he says: "For I wished myself to be an anathema from Christ, for my brethren, who are my kinsmen according to the flesh", i.e. "I should wish to be separated and rejected of Christ, if by that means I would procure the salvation of my brethren." And again, using the word in the same sense, he says (Galatians 1:9): "If any one preach to you a gospel besides that which you have received, let him be anathema." But he who is separated from God is united to the devil, which explains why St. Paul, instead of anathematizing, sometimes delivers a person over to Satan (1 Timothy 1:20; 1 Corinthians 5:5). Anathema signifies also to be overwhelmed with maledictions, as in 1 Corinthians 16:22: "If any man love not our Lord Jesus Christ, let him be anathema." At an early date the Church adopted the word anathema to signify the exclusion of a sinner from the society of the faithful; but the anathema was pronounced chiefly against heretics. All the councils, from the Council of Nicæa to that of the Vatican, have worded their dogmatic canons: "If any one says . . . let him be anathema". Nevertheless, although during the first centuries the anathema did not seem to differ from the sentence of excommunication, beginning with the sixth century a distinction was made between the two. A Council of Tours desires that after three warnings there be recited in chorus Psalm cviii against the usurper of the goods of the Church, that he may fall into the curse of Judas, and "that he may be not only excommunicated, but anathematized, and that he may be stricken by the sword of Heaven". This distinction was introduced into the canons of the Church, as is proved by the letter of John VIII (872-82) found in the Decree of Gratian (c. III, q. V, c. XII): "Know that Engeltrude is not only under the ban of excommunication, which separates her from the society of the brethren, but under the anathema, which separates from the body of Christ, which is the Church." This distinction is found in the earliest Decretals, in the chapter Cum non ab homine. In the same chapter, the tenth of Decretals II, tit. i, Celestine III (1191-98), speaking of the measures it is necessary to take in proceeding against a cleric guilty of theft, homicide, perjury, or other crimes, says: "If, after having been deposed from office, he is incorrigible, he should first be excommunicated; but if he perseveres in his contumacy he should be stricken with the sword of anathema; but if plunging to the depths of the abyss, he reaches the point where he despises these penalties, he should be given over to the secular arm." At a late period, Gregory IX (1227-41), bk. V, tit. xxxix, ch. lix, Si quem, distinguishes minor excommunication, or that implying exclusion only from the sacraments, from major excommunication, implying exclusion from the society of the faithful. He declares that it is major excommunication which is meant in all texts in which mention is made of excommunication. Since that time there has been no difference between major excommunication and anathema, except the greater or less degree of ceremony in pronouncing the sentence of excommunication.
Anathema remains a major excommunication which is to be promulgated with great solemnity. A formula for this ceremony was drawn up by Pope Zachary (741-52) in the chapter Debent duodecim sacerdotes, Cause xi, quest. iii. The Roman Pontifical reproduces it in the chapter Ordo excommunicandi et absolvendi, distinguishing three sorts of excommunication: minor excommunication, formerly incurred by a person holding communication with anyone under the ban of excommunication; major excommunication, pronounced by the Pope in reading a sentence; and anathema, or the penalty incurred by crimes of the gravest order, and solemnly promulgated by the Pope. In passing this sentence, the pontiff is vested in amice, stole, and a violet cope, wearing his mitre, and assisted by twelve priests clad in their surplices and holding lighted candles. He takes his seat in front of the altar or in some other suitable place, amid pronounces the formula of anathema which ends with these words: "Wherefore in the name of God the All-powerful, Father, Son, and Holy Ghost, of the Blessed Peter, Prince of the Apostles, and of all the saints, in virtue of the power which has been given us of binding and loosing in Heaven and on earth, we deprive N-- himself and all his accomplices and all his abettors of the Communion of the Body and Blood of Our Lord, we separate him from the society of all Christians, we exclude him from the bosom of our Holy Mother the Church in Heaven and on earth, we declare him excommunicated and anathematized and we judge him condemned to eternal fire with Satan and his angels and all the reprobate, so long as he will not burst the fetters of the demon, do penance and satisfy the Church; we deliver him to Satan to mortify his body, that his soul may be saved on the day of judgment." Whereupon all the assistants respond: "Fiat, fiat, fiat." The pontiff and the twelve priests then cast to the ground the lighted candles they have been carrying, and notice is sent in writing to the priests and neighbouring bishops of the name of the one who has been excommunicated and the cause of his excommunication, in order that they may have no communication with him. Although he is delivered to Satan and his angels, he can still, and is even bound to repent. The Pontifical gives the form for absolving him and reconciling him with the Church. The promulgation of the anathema with such solemnity is well calculated to strike terror to the criminal and bring him to a state of repentance, especially if the Church adds to it the ceremony of the Maranatha.
The Church, animated by the spirit of God, does not wish the death of the sinner, but rather that he be converted and live. This explains why the most severe and terrifying formulas of excommunication, containing all the rigours of the Maranatha have, as a rule, clauses like this: Unless he becomes repentant, or gives satisfaction, or is corrected.