It's not enough for you to be able to swim, bike, and run faster than you are now; hell, it's not even enough for you to go faster than the competition. Your best pace in a tempo run, your smoothest technique in the open water, your fastest speed on your bike isn't going to matter a lick if you can't call upon it (and a little more) when race day rolls around.
Triathlon is an inherently painful sport; all endurance sports, actually, entail more suffering than most humans (at least humans in our culture) are comfortable with. So when the intense discomfort of racing near your limits smacks you in the face, what do you turn to? How do you ensure that the hard work you've put in leading to your A race doesn't fizzle out when you need it most?
One way is to establish a rival. This is what I did for the Boathouse International Triathlon. I checked the list of registered athletes for women in my age group; I looked up their USAT rankings and previous race performances, trying to determine which ones would pose a threat. I found race pictures of them online and posted them above my desk (note: this creeps people out) with their times from races I'd also been at last year. Seriously. Ask my co-workers and clients. I had to look at those pictures every day, and before going out on training runs, I would see those photos and get a surge of adrenaline that told me, You want it more than they do.
Another method I've used with great success is focusing on a mantra--a phrase you repeat to yourself constantly to drown out the noise of pain and stink of lactate in your body. The best one I've found so far is "Trust the work"; that's what brought me through my first 70.3. But you can use any phrase that you find appealing. Works best when it's short, succinct, and burns an image in your brain. One of my athletes likes to use "Slow and steady"; another took herself through her first tri with the phrase "Home stretch." Keep it appropriate to your goals, though; if you're looking to podium for the first time, "Just finish" is probably not going to be immensely helpful to you.
My favorite method is to get a song stuck in my head. This can be tricky, if you're not a particularly musical person. It can also disrupt your rhythm if you try to match your cadence to an inappropriate song. And I've found that I can't always choose what song ends up swirling around in my brain (it's been this one in every workout I've done for the past two weeks, which is downright annoying). But when your brain hits on the right song--maybe something from your pre-race playlist--and it keeps coming back to (again) drown out the noise of your body, it's golden.
A key thing to note is that different methods are going to work differently for each individual. Personally, the rivalry thing doesn't prompt me to push myself into the realms of true pain. Speedy, on the other hand, thrives on that kind of competition. "Trust the work" brought me to a new half marathon PR, because I knew that I could run 2:15, and I just had to stay on the pace I knew I could run. But when you're racing against other people, it's less effective, because you have to trust that your work is also better than theirs. My most successful method is the song, because I can completely let go and take my brain out of my body. I still have to maintain enough focus and awareness to keep the legs turning over, but I no longer have to think about how bad it's hurting or how much I want it to be over already.
At this point, all I can do is offer you these three strategies, with examples of how they've worked for me. But I'm sure there are other strategies out there. Best bet is to ask more experienced athletes what they do to push themselves through the pain to the next level on race day. Experienced athletes, do you have anything to add? How do you mentally prepare for and execute your race in order to get the most out of training?