It's virtually impossible to change your score in the time between when most people decide to buy a home or refinance their mortgage and when they apply. So the short answer is, you really can't "on the spot." But there are strategies you can live with to make sure when you apply for a loan your score is as high as possible.
Make sure that the information each of the three credit reporting bureaus has on you is consistent and up to date. Order a copy of your credit report about once a year, and dispute any inaccuracies.
Note: Theoretically, if a series of credit reports is requested on your behalf during a limited amount of time, your score goes down until time passes without any inquiries. Changes in the law though have made "consumer-originating" credit report requests not count so much. Also, a series of requests in relation to getting a mortgage or car loan is not treated the same as a number of credit card requests in a limited time. This is because the credit bureaus, and lenders, realize that people request their own credit reports to keep up with what's on them, and smart consumers shop around for the best mortgage and car loans.
Unsolicited credit card solicitations in the mail don't count against your credit report, so don't worry.
The two main components of your credit score are your payment history and the amounts you owe. Bankruptcy filings and foreclosures, which can stay on your credit report for as long as 10 years, can significantly lower your score. It's never a good idea to take on more credit than you can handle.
Late payments work against you. It's extremely important to pay bills on time, even if it's only the monthly payment.
Don't "max out" your credit lines. Since the size of the balance on your open accounts is a factor, lower balances are better.
It's said that by carefully managing your credit, it's possible to add as much as 50 points per year to your score