It depends on where you plan on inserting the code. If it's not within an area that is editable through your CONTENT items, then you can go to the TEMPLATE MANAGER and edit the HTML for your template. This is necessary when you want to modify headers through PHP, etc, because PHP headers have to be before any other output on a page.
If you do want to put the PHP within a CONTENT item, then you can get the MosSnippet mambot, that's what I prefer to use. It's the most straight-forward with the most flexibility.
Joomla! Extensions: MosSnippet