You can download the sample code from the following site:
The sample code is mainly for the capability and performance check, it is little bit complicated and you need the effort to start your project. The sample_encode project has the code for JPEG encoding. For a quick source code check you can click the link in this page to the GitHub.
Here is a quick review:
After user input the parameters, the sample_encode calls the pipeline init function to call InitMfxEncParam() function to configure the encoder, this section of code is the place to configure the JPEG encoder.
The other source is the tutorial code, which is relatively simple and easy to start with, unfortunately it doesn't have the implementation for JPEG. But since it shows the implementation flow, you can use the knowledge from the sample_encode and apply the JPEG configuration to the simple_encode project.
Let me know if you have further questions.