I am filing 2013 federal tax using 1040 form, and 2013 Maryland tax using 502 form.
I have moved away from Maryland in 2014. So I wonder if I should use my current address or my old and invalid address in 2013 in the two forms? Thanks!
No, always give the most current address information to the IRS, not least because they will use this address to send you important communications, such as refund checks or notices of deficiency.
Per the 1040 Instructions, you should put in your address, with no mention of past addresses. Moreover, if you will change addresses after filing, the IRS has provided Form 8822 to notify them of the new address. There is a similar Form 8822-B for business addresses.
They will use your Social Security Number (SSN), Individual Taxpayer Identification Number (ITIN), or Employer Identification Number (EIN) to track who you are. There's no point to purposely giving an invalid address, and in fact it's technically illegal since you will sign and certify the return as true and accurate to the best of your knowledge.