Modulating ofdm in audio spectrum
Typically you use Orthogonal Frequency Division Multiplexing (OFDM) with communications. In this context having complex data in the time domain makes sense because the real and imaginary parts of the number represent the inphase and quadrature parts of the signal.

In an audio signal which is what a wav file is used for is only real. As sound is a naturally occurring signal.

I am not sure why you'd want to store the inverse of an FFT in a wav file (listening to it would sound awful). As you've discovered there's no way of guaranteeing that this data is real. You seem to get around this by taking the real part of the output and only writing that to your file.

However, if I assume you need this data stored in a wav file you could store the real and imaginary part in the wav file by interleaving them. You could write something like:

towav = zeros(length(outputiFFT)*2);
towav(1:2:end-1) = real(outputiFFT).*cos(-2*pi*fc/44100*(0:length(outputiFFT)-1));
towav(2:2:end) = imag(outputiFFT).*sin(-2*pi*fc/44100*(0:length(outputiFFT)-1));


in your code above.

Bear in mind this "halves” your sample rate when you write the 'towav' variable to your wav file. Although I am assuming you don't need to listen to the file, so this is unlikely to matter.

EDIT: as the comment below points out if you weren’t generating random QPSK signals and you ensured that the input sequence in the frequency domain was conjugate symmetric you would have a real sequence in the time domain and you would not need to store the imaginary part.