Can CMAC be used as a 128bit Key Derivation Function? I want to derive a key a number of times for a deterministic scenario, where I can get n keys from a single one.

The logic looks something like this:

masterKey = random 128-bit
For i from 0 to n:
    let key[i] = CMAC(masterKey, i)


Is this a proper way to generate a number of keys or does this have a flaw?
CMAC(masterKey, i) should generally suffice, yes. Note that you would need to specify an encoding for i (e.g. octet string consisting of the big endian encoding of i, left-padded with zero valued octets up to 4 octets).

It's probably better to implement one of the schemes defined in NIST SP 800-108: "Recommendation for Key Derivation Using Pseudorandom Functions" though. Note that CMAC is a Pseudorandom Function (PRF) and is mentioned explicitly in this standard.

I'd recommend the NIST SP 800-108 counter mode (section 5.1), which is relatively commonplace and easy to implement. Note that the counter i in the standard is different from your definition of i. The i in the standard is used to derive more keying material for a single key than can be generated by the PRF (i.e. more than 128 bits in the case of AES-CMAC). Your i should be encoded in the Context variable if you follow the standard to the letter.