This is a deeply philosophical question about the ontology of words. Specifically, it is a question about the individuation conditions of words. This question, sadly, has no answer given that we use the word "word" very inconsistently (see below).
Many syntacticians prefer to talk about lexical items rather than words, given the nebulousness of the concept word. Lexical items (on at least one use of the term) are individuated by syntactic category (among other things).
Thus, cook (qua noun) is taken to be a distinct lexical item from cook (qua verb).
Drastically different (and etymologically unrelated) meaning is also a criterion for distinctness of lexical items. For example, bank (qua riverside) is taken to be a distinct lexical item from bank (qua financial institution), since these two uses have radically different meanings and etymologies.
The problem with discussing the individuation conditions of words themselves is that English speakers' use of the word "word" is very inconsistent. In different contexts, we use the word "word" to pick out different things, with different individuation conditions. Sometimes we use "word" to refer to phonic-graphic types (that is, general arrangements of sounds and/or letters), sometimes to tokens (that is, particular utterances or inscriptions of these types), sometimes to phonic-graphic types plus meanings, sometimes to phonic-graphic types plus meanings and syntactic categories, and so on. This context-sensitivity of the word "word" is discussed by at least a few of the philosophers who have thought about the ontology of words.
If you are interested in pursuing the (relatively small) literature on the ontology/metaphysics of words, here are a few good papers:
Alward, Peter. “Between the Lines of Age: Reflections on the Metaphysics of Words.” Pacific Philosophical Quarterly 86 (2005): 172-187.
Bromberger, Sylvan. “What Are Words? Comments on Kaplan (1990), on Hawthorne and Lepore, and on the Issue.” Journal of Philosophy 108, no. 9 (2011): 486-503.
Cappelen, Herman. “Intentions in Words.” Nous 33, no. 1 (1999): 92-102.
Hawthorne, John and Ernest Lepore. “On Words.” Journal of Philosophy 108, no. 9 (2011): 447-485.
Kaplan, David. “Words.” Proceedings of the Aristotelian Society, Supplementary Volumes 64 (1990): 93-119.
Kaplan, David. “Words on Words.” Journal of Philosophy 108, no. 9 (2011): 504-529.
McCulloch, Gregory. “Making Sense of Words.” Analysis 51, no. 2 (1991): 73-79.
Stainton, Robert. “Meaning and Reference: Some Chomskyan Themes.” In The Oxford Handbook of Philosophy of Language, edited by E. Lepore and B. C. Smith. Oxford: Oxford University Press, 2006.
Wetzel, Linda. "On Types and Words." Journal of Philosophical Research 27 (2002):239-265.
Wetzel, Linda. Types and Tokens: On Abstract Objects. Cambridge, MA: The MIT Press (2009)