Why put a comma before "too" when meaning "as well" but not before words that can be used in place of "too?"

First of all, both the version with a comma and the version without a comma are grammatically acceptable for both too and as well. Especially in the case of too (in American English, when it is at the end of the sentence), the decision whether to put a comma is largely a matter of style, despite the fact that some speakers detect a difference in meaning. Moreover, the comma seems far more common in American English than in British English; indeed, in American English the version with a comma is slightly preferred, while in British English the comma is pretty strongly disfavored (see below).

On the other hand, in the case of as well, both American and British English strongly disfavor the comma, although in American English the disfavoring is not as strong as in British English.

Thus, especially in American English, but even in British English, the comma is much more acceptable before too than before as well. An obvious follow-up to your question might be to ask why there is this difference between too and as well. At the moment at least, I have to say that I don't know. All I can say is that I see little hope in being able to find a reason from the semantics and grammar of contemporary English. (In the semantics and grammar of contemporary English, when as well and too are placed at the end of a sentence, they are indeed extremely similar.) Therefore, the reason is likely to lie within diachronic (historical) linguistics rather than in synchronic linguistics (the latter views linguistic phenomena only at a given time, usually the present).

Discussion

Too vs. as well

In the usage we are discussing, too and as well function as focusing modifiers of the additive type, a group which also includes in addition, also, and even (CGEL, pp. 592-595). While as well and too in this function are very similar, they are not completely interchangeable. For example, in

Sue bought a CD too.

the too can be readily replaced by as well; however, in

I too think the proposal has merit.

the replacement is possible, but not as felicitous (CGEL, 593).

The comma before too

About the comma before too, here is what The Chicago Manual Of Style (CMoS) FAQ had to say (here):

Q. Please help clarify a debate over what I see as a groundless but persistent carryover from high-school English classes: the comma-before-too “rule.” The rule goes something like this: When “too” is used in the sense of “also,” use a comma before and after “too” in the middle of a sentence and a comma before “too” at the end of a sentence. I am editing a work of fiction in which the author has rigidly applied the rule. I have just as rigidly deleted the commas. My managing editor believes that a comma is needed when “too” refers to an item in a list and has the sense of “in addition” (e.g., “I like apples and bananas, too.”), but she would omit the comma when “too” refers to the subject of the sentence (e.g., “Oh, you like apples and bananas? I like apples and bananas too.”). My managing editor’s rule helps make a useful distinction, but I am still wondering whether the comma is ever grammatically justified.

A. A comma can do some work in making the meaning of a sentence clear, but to claim two different meanings for I like apples and bananas too with and without a comma before too puts too much pressure on the comma. Out of context, neither version would be perfectly clear. To make the different meanings more apparent, short of additional context, you’d have to be more explicit:

I, too, like apples and bananas.
I like not only apples but bananas too.

Use commas with too only when you want to emphasize an abrupt change of thought:

He didn’t know at first what hit him, but then, too, he hadn’t ever walked in a field strewn with garden rakes.

In most other cases, commas with this short adverb are unnecessary (an exception being sentences that begin with too—in the sense of also—a construction some writers would avoid as being too awkward).

Having said that, if you search the Corpus of Contemporary American English (COCA) for too at the end of the sentence, you find lots of hits both with and without the preceding comma, and even if you constrain the search to academic sources only: for academic sources, 938 hits (45%) are without a comma, and 1149 (55%) are with. Here is a snapshot of some of them:

enter image description here

If a similar search is performed in the British National Corpus (BNC), the version with a comma is far more rare: among academic sources, 287 (84%) are without a comma, and 55 (16%) are with one.

The comma before as well

In contrast, if you do a similar search on COCA for as well, almost none of the hits come with a preceding comma: for academic sources, 5991 (95%) are without a comma, and 320 (5%) are with.

enter image description here

The one exception in the preceding list is

Arts and crafts projects can easily coordinate with the theme of the projects, as well.

On BNC, the breakdown (again for academic sources) is 358 (99%) without, and 3 (1%) with.