It is the same usage as loaf in "a loaf of bread" or slice in "a slice of bread."
It is not always necessary to use "ear" when speaking of corn, when it is obvious that the whole ear is involved. For example, "corn is roasted on the grill" obviously means the whole ear is placed on the grill. You could not do otherwise. When boiling corn, however, you might want to state that "whole ears of corn are boiled," because it's also possible to boil canned corn. Ears of corn are also sometimes called "corn on the cob," and loose kernels of corn can be called "corn off the cob."