Hash function composition - security level When using two hash functions, g(x)=SHA-512 and f(x)=MD5
g(x) has 512 bit output (using salt)
f(x) has 128 bit output.

Let's say that z(x)=f(g(x))
meaning the output is 128 bit long.

The Question:
Is using z(x) like using MD5 with salt? Hence, the security level is low.
Opposed to using only g(x) with salt and getting 512 bit long output?

On the one hand z(x) is a more complex function than g(x) but on the other hand 512 bit should take longer time to crack vs 128 bit.
z(x) is equivalent to f(x) for your use case. MD5 has known collision vulnerabilities, so your overall output will suffer from the same vulnerabilities. Also since the output is 128 bits long it is discarding the additional security margin of having a longer hash output. 

Using SHA-512 alone is safer. If length extension attacks are an issue either use SHA-512/256, SHA3, Blake2b, HMAC, or another secure hash function immune to such attacks.