The cosine and sine components, or the real and imaginary components of a complex DFT, can also be thought of as the even and odd decomposition of a waveform. For a waveform to have pure sine components (no added phase due to a non-zero cosine components), the waveform must be purely odd, thus has to be anti-symmetric around the center of the DFT/FFT window. And only a sine wave with a phase of zero or pi at the center of a window is a purely anti-symmetric sinusoid in that window for any frequency.
So to create your sine wave with a DFT phase of pi/2, you need to start your sine wave with a phase of zero or pi at the center (N/2) of your vector of N=1024, not zero or pi or pi/2 at the left end. This guarantees that it is anti-symmetric for any frequency (not just DFT/FFT bin-center frequencies).
Note that pure sinusoids that are not exactly integer periodic in aperture will have a discontinuity between the left and right ends of the vector or DFT window (as well as have a non-zero magnitude in multiple DFT result bins). That's why you can't start arbitrary frequency sinusoidal synthesis with a phase of zero or +-pi/2 at either end if you want a guaranteed DFT phase of +-pi/2.