Yes, it does. "Grammar" is a pretty vague term though; in fact, phonology (the study of the sound systems of languages) is apparently considered part of its scope. Aside from that, the section of grammar that is most obviously connected to phonetics is "morphology," which deals with the grammatical structure within single words. As you've noticed, the suffix /z/, which is used to mark the plural of nouns, the present-tense singular of verbs, and the genitive of nouns or noun phrases, regularly takes different forms depending on the preceding sound. The past tense suffix /d/ is regularly devoiced to [t] after a voiceless consonant, and irregularly in other contexts for some words such as "dreamt" and "burnt." The suffixes "-er" and "-est" tend to be used to form the comparative of adjectives with fewer syllables, while the separate words "more" and "most" tend to be used with adjectives that have more syllables.
Spelling the plural of words with "o" as "oes" doesn't have anything to do with phonetics, though. It's purely a written convention.