You need to extract the value of the custom metabox (be this background color or background image) and then, once you validate to make sure it has a value, which one is empty or what happens if both have values, to determine an INLINE-STYLING on the following piece of code:
<section id="masthead" style="background-image:<your dynamic value here>">
Just make sure you validate the scenarios of what if they fill a color but no image, what if they fill an image but no color, what if they fill both (on the metabox), what if they place none, etc.