Go to your themes/default folder and find UltimateProfile.template.php. Open it and search through, find the spot you wish to insert your code. Make sure you make a backup of the file first. If you have trouble finding where to put it, try to look for chunks of code in comparison to what is being shown on the profile page, and look for the best fit. If it doesn't show up where you want it, you can always move your code.
When you've found a spot, paste your code in. Your code starts and ends in php, so make sure you don't paste your code where html is, try to keep it separate (notepadd++ is great for this stuff). Then scroll up until you see the start of the function that you pasted your code into, it will say function something(something else). Shortly after there is a line that says "global $something, $somethingElse," etc. Make sure that $scripturl, $modSettings, and $message are also entered there if they are not already.