When to use linear or logistic regression?
Linear Regression is used for predicting continuous variables.

Logistic Regression is used for predicting variables which has only limited values.

Let me quote a nice example which can help you make the difference between the both:


  For instance, if X contains the area in square feet of houses, and Y
  contains the corresponding sale price of those houses, you could use
  linear regression to predict selling price as a function of house
  size. While the possible selling price may not actually be any, there
  are so many possible values that a linear regression model would be
  chosen.
  
  If, instead, you wanted to predict, based on size, whether a house
  would sell for more than 200K, you would use logistic regression. The
  possible outputs are either Yes, the house will sell for more than
  $200K, or No, the house will not.