This depends on the nature of the agreement you reached with your employer. If you agreed to try out a period of working from home on a temporary basis and it hasn’t worked out, then you should be allowed to return to your office-based role, assuming it still exists.
If, on the other hand, you agreed to a permanent arrangement, it is likely to be harder to reverse, especially if your employer has invested in equipment to enable you to work from home, if someone else has been slotted into your office-based role, or if the office has downsized, relocated, or even shut down altogether. At the very least, your employer should consult with you and see what can be agreed.
If you are struggling to adjust to working at home, it may be helpful to focus on exactly what it is you don’t like, and on ways in which the arrangement could be adjusted, rather than abandoning it altogether. For example:
Can you agree with your employer to spend fewer hours working at home?
Is enough being done to make sure you still get to see and speak to colleagues on a regular basis? Your employer has a duty to take reasonable care of your health, and this includes your mental health.
Is enough being done to maintain your relationship with your line manager when you are working at home?
Are you looking after your own health by taking sensible breaks, including a proper lunch break, preferably getting some fresh air and certainly away from your desk?
Are you maintaining a clear start and end to your working day?
Not everything about working from home is positive. A study by the International Labour Organisation (ILO), Working anytime anywhere, the effects on the world of work, has found that working remotely can lead to insomnia and raised levels of stress.