You can do that by setting the GotRefDist=1 in mfxInfoMFX structure. You can find more information in the mediasdk-man.pdf (p120) in <MEDIASDK>/doc folder. To quote from the manual (you can find an example code on p123 in the same manual).
Distance between I- or P- key frames; if it is zero, the GOP structure is unspecified. Note: If GopRefDist = 1, there are no B-frames used. See Example 14 for pseudo-code that demonstrates how SDK uses this parameter.
When setting the mfx structure, you can set this flag as well. You can find an example in the simple_6_encode_vmem_lowlatency tutorial.
You can find the tutorials in the "TUTORIALS" tab in this page: https://software.intel.com/en-us/media-solutions-portal
Here is the direct link to download the tutorials zip file: http://software.intel.com/sites/default/files/mediasdk-tutorials-0.0.3.zip