You could use either "kokken" or "kokka" to refer to a female chef, though gendering job titles is becoming less and less common, so most dialects would have a preference for "kokken" when referring to either sex.
"O" in "kokk" sounds like [u], and changes to [o] in "kokken". In contrast "o" [u] in "bok" and "boken" stays the same.
Is it something that you should only remember for each such word? Or is there a general rule?
From what ive seen, when its a long vowel its pronounced [u]. When its a short vowel its pronounced [o]. However, a lot pf the short words like og can be exceptions and you'll just have to learn those by themselves