All right, so you’d like to get started with scripting Photoshop?
Adobe’s website has a page for Photoshop Scripting. For each different version, there is an introductory guide and a reference manual with all the details of the object model.
You’ll be writing code in JavaScript. Technically you can also script Photoshop using AppleScript on the mac and VBScript on Windows, but JavaScript works cross-platform, you probably know it better than the other languages, and it’s much easier to find help for.
The program ExtendScript Toolkit got installed on your computer when you installed Photoshop. It’s an IDE for scripting Adobe applications. Launch it. In the Scripts panel, select Photoshop as the target, and you’ll see that several Photoshop features like “Merge to HDR” and “Photomerge” are implemented in JavaScript, and you can view their source code.

To get started writing your own scripts, create a sample image in Photoshop:

Then go to ExtendScript Toolkit, set the script target to Photoshop in the upper-right-corner dropbox box, and play around in the JavaScript Console:

By playing around, you’ll find that you can change the text with this JavaScript:
app.documents[0].artLayers[0].textItem.contents = "hello 2"

If you’re happy with the script, save it, and then you can run it from Photoshop using File → Scripts → Browse…
Once you know the basics of scripting Photoshop, solving your labeling problem should be a lot more straightforward. You’ll probably want to start by creating a new document for each page that will be printed. Then for each label, copy the elements of the template file into the document for the page that the label should be printed on. Adjust the positions of the elements, and change the text to match the label number…