By Kylie MacLellan

LONDON (Reuters) - It would not be the "right answer" for Britons to vote to leave the European Union, but the government will have to make it work if they do, Prime Minister David Cameron said on Sunday.

An opinion poll published on Thursday showed that a majority of Britons who have made up their mind would back leaving the EU in a referendum due by the end of 2017.

Cameron said he hoped voters would back staying in the EU if he achieves his planned reforms to Britain's relationship with the bloc.

"The British public will make their decision. We must obey that decision whatever it is," he told the BBC's Andrew Marr show. "I don't think that (exit) is the right answer ... Were that to be the answer, we would have to do everything necessary to make that work."

Asked whether the government was making contingency plans for a possible exit, Cameron said it had plans for the renegotiation and referendum.

"The civil service is working to help me deliver those things. Now, if we fail to deliver them and we have to take a different stance, then that is a new situation," he said.

Arron Banks, co-founder of 'out' campaign group Leave.EU said Cameron would not be taken seriously in his renegotiation if he was not prepared to walk away from the bloc.

"David Cameron's lack of a plan for withdrawal tells the EU, and voters, that he has no intention of leaving, guaranteeing that the deal he does finally produce won't be worth the paper it's written on," he said.

MASSIVE PRIZE

Cameron, who travelled to Germany and Hungary last week to hold talks on his proposed reforms, said he was confident a deal could be reached on what has proved the biggest sticking point - his plans to curb welfare payments to EU migrants.

He said he believed the "massive prize" of reforming Britain's relationship with the 28-nation bloc and staying a member was closer than it had been and he was hopeful of striking a deal at a meeting of EU leaders next month.

Story continues

The Conservative Party leader, who has said he will not seek a third term at a national election due in 2020, also repeated a comment made earlier this week that he did not plan to stand down as prime minister if he loses the referendum.

Eurosceptic Conservative lawmaker and former minister David Davis told the BBC he thought as many as two thirds of the party's lawmakers and five or six of Cameron's top team of ministers could vote to leave the bloc.

A referendum could follow about four months after a deal. Cameron said that if an agreement were not reached in February, the vote could be held in September "or later".

"The substance matters much more than the timing, so if I can't get the right deal in February, I will wait and I will keep going and keep plugging away," he said.

(Reporting by Kylie MacLellan; Editing by Mark Heinrich and Digby Lidstone)