Is there a difference between using a lawyer or an agent for my real estate transaction? 

Absolutely. 

Which one should I use?

It depends. The Journal of Finance and Accountancy actually investigated the advantages and disadvantages of hiring a real estate agent vs. hiring a lawyer. The study found that hiring the real estate agent in most real estate transactions would be in the consumer’s best interests.

Here's the excerpt from their conclusion:

In a perfect world, where money is no object, it would be definitely in the consumer’s best interest to hire both a real estate broker / agent and an attorney to hlp guide, protect, and generally look after his best interest in a real estate transaction. In many states the consumers are legally required to hire both (www.nolo.com). This study applies to the states in which people have to make that decision of who to hire when buying, selling, or leasing real estate. From the research gathered, the authors conclude that it is in the consumer’s best interest to hire the real estate agent / broker in most transactions. With that being said, there is still a time and a place to hire a real estate attorney. An example of this could be if a consumer is selling, buying, or leasing real estate from a family member or close friend in which there is no need for an intermediary, but there is still a need for legal protection and guidance. There will always be a need for real estate brokerage services regardless of whether sales prices are made public in the state of Texas. It makes sense to hire a professional in the field. If a consumer has a plumbing issue in the house, he would not hire an electrician to fix the problem. So why would it make sense to hire an attorney to assist your real estate transaction? An attorney’s specialization is real estate law and his or her fluency in legal language. A broker / agents’ specialization is in the sale, purchase, and leasing of real estate. Based on the research gathered, the authors can conclude that the broker / agent is the most advantageous choice.